+ 1
What is the meaning of *x = *x +1?
#include <iostream> using namespace std; void printSomething(int * x) { *x = *x + 1; cout << *x << endl; } int main() { int x = 42; int* px = &x; cout << x <<endl; printSomething(px); cout << x << endl; } Does it increment the location address by 1 ?for eg.if the location address of x is 02xff18 so after execution it will be 02xff19
1 ответ
+ 4
No, it increments the value.
void printSomething(int * x) {
x += 1;
}
Would do this because *x means the value, x means the location.