Segmentation Fault in Linux

Hello, I am new to C++ and a little inexperienced in Linux. I coded my cpp program in Windows and it's compiling and running perfectly fine. However, when run in Linux, there were compiler errors. I managed to look for workarounds so the program compiled and ran.

But when I get user inputs:

1
2
3
4
5
char name[] = " ";
int age;

cin >> name;
cin >> age;


It doesn't work. And on the first cin >>, I get Segmentation Fault error. I tried

1
2
getline(cin, name); 
getline(cin, age);


But it doesn't compile anymore. Can anybody help me on this? Thanks so much in advance!
char name[] = " " allocates enough space for 2 characters, the space and the \0.

getline() only works with std::strings, not char* (cstrings).
Thanks!
My program worked now.
I used char name[256].
Topic archived. No new replies allowed.