+ 5

i wanted to know..can we include pointers in the parameters directly..as we use int,double,char,etc..

can someone help me with this.??

29th Sep 2017, 6:51 PM
Omkar Tripathi
Omkar Tripathi - avatar
2 Antworten
+ 2
#include <iostream> using namespace std; void myFunc(int *p) { *p = *p + 1; // or ++*p } int main() { int n = 5; myFunc(&n); cout << n; return 0; }
29th Sep 2017, 7:07 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Yes we can pass a pointer as a parameter but keep in mind that while calling the function you need to pass the address of the required variable otherwise it would result in garbage
4th Oct 2017, 4:20 AM
dhiman mishra
dhiman mishra - avatar