Implementation of Project
Learn about the implementation detail of function pointer parameters and arithmetic programs both collectively.
Function pointer parameters project
It is our final project and a summary of the project source code.
FunctionParameters
The source code of the FunctionParameters
project is given below:
Press + to interact
// FunctionParameters.cppint main(int argc, char* argv[]){int a, b;printf("Enter a and b: ");scanf("%d %d", &a, &b);if (arithmetic (a, &b)){printf("Result = %d", b);}return 0;}
Arithmetic program
The source code of the arithmetic program is given below:
Press + to interact
// Arithmetic.cppbool arithmetic (int a, int *b){if (!b){return false;}*b = *b + a;++a;*b = *b * a;return true;}
Commented disassembly
Here is the commented disassembly we get after compiling the project and loading it into GDB:
gcc FunctionParameters.cpp Arithmetic.cpp -o FunctionParameters
gdb ./FunctionParameters
After compiling and loading, we should see the following in the GDB container:
...