1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
void MyFunc(int *x);
int main()
{
int z=5;
MyFunc(&z);
std::cout<<z;
return 0;
}
void MyFunc(int *x)
{
*x = (*x)+1;
}
| |
I've added to the function +1 instead of ++, because MinGW and VS have difference otherwise.
So my case shows 6 in both cases(VS and MinGW)
Or it can have the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
void MyFunc(int *x);
int main()
{
int z=5;
MyFunc(&z);
std::cout<<z;
return 0;
}
void MyFunc(int *x)
{
*x = ++(*x);
}
| |
The result is 6 of course on both compilers
Last edited on