My main() crashes below when add(4) is called.
As I understand int* add, it should return a pointer to integer. Then, I should be able in main to say:
int * a = add(3);
to return a pointer to int.
Please explain what I'm doing wrong.
#include <cstdlib>
#include <iostream>
using namespace std;
int* add (int a) {
int * c, d;
d = a + 1;
*c = d;
cout << "c = " << c << endl;
return c;
}
int main(int argc, char *argv[])
{
int a = 4;
int * c;
c = add(4);
system("PAUSE");
return EXIT_SUCCESS;
}