Browse Source

fixed ptrFuncs code again

master
Sudipto Ghosh 5 months ago
parent
commit
d6f2bd5256
Signed by: Sudipto Ghosh <sudipto@ghosh.pro> GPG Key ID: FDE756FE89D3B4FF

+ 0
- 2
.gitignore View File

@@ -6,6 +6,4 @@ x86
*.ilk
*.pdb
*.obj
*.exe
main
.vscode

+ 7
- 7
Year I/Semester I/C++/Other/07-09-2019/ptrFuncs/main.cpp View File

@@ -27,16 +27,16 @@ int main()
cout << left << setfill(' ');

cout << setw(10) << "num: ";
printf("%X\n", &num);
printf("%p\n", &num);

cout << setw(10) << "square(): ";
printf("%X\n", square);
printf("%p\n", square);

cout << setw(10) << "func1(): ";
printf("%X\n", func1);
printf("%p\n", func1);

cout << setw(10) << "func2: ";
printf("%X\n", &func2);
printf("%p\n", &func2);

cout << endl;

@@ -48,11 +48,11 @@ int main()

cout << setw(6) << "pnum"
<< "=> ";
printf("%X\n", pnum);
printf("%p\n", pnum);

cout << setw(6) << "func2"
<< "=> ";
printf("%X\n", *func2);
printf("%p\n", *func2);

cout << endl;

@@ -70,7 +70,7 @@ int main()
cout << "Executing func1(" << *pnum << ") ..."
<< endl;
cout << setw(10) << "Output: ";
printf("%X\n", func1(*pnum));
printf("%p\n", func1(*pnum));

cout << "Executing func2(" << *pnum << ") ..."
<< endl;

BIN
Year I/Semester I/C++/Other/07-09-2019/ptrFuncs/main.exe View File


+ 13
- 13
Year I/Semester I/C++/Other/07-09-2019/ptrFuncs/output.txt View File

@@ -1,26 +1,26 @@
Enter a number: 5
Enter a number: 145

Memory
--------------------------
num: 61FE04
square(): 401BA5
func1(): 401BBA
func2: 61FDF8
num: 000000000061fe04
square(): 0000000000401ba5
func1(): 0000000000401bba
func2: 000000000061fdf8


Pointers
--------------------------
pnum => 61FE04
func2 => 401BA5
pnum => 000000000061fe04
func2 => 0000000000401ba5


Output
--------------------------
Executing square(5) ...
Output: 25
Executing func1(5) ...
Output: 61FE04
Executing func2(5) ...
Output: 25
Executing square(145) ...
Output: 21025
Executing func1(145) ...
Output: 000000000061fe04
Executing func2(145) ...
Output: 21025

Press return to continue ...

Loading…
Cancel
Save