First you declare
char* Name;
while you use
cin.getline(name, 15);
Name and
name are different, but I guess you have corrected it.
Also
cout << line;
Where do you declare
line? I doubt this code compiled in that form...
So to correct your code in this form follow the suggestion of allocating memory for the pointer. For example...
char* name = (char*) malloc(SIZE_IN_BYTES_OF_MEMORY_REQUESTED);
Do not forget to free it up when done using it.
free(name);
Finally, since you use using C++ you are better off using C++ facilities, like the string class. So you could make these changes
#include <iostream>
+#include <string>
using namespace std;
int main()
{
- char *name = (char*) malloc(20);
+ string name;
cout << " Enter your name with space(E.g Joe Mark)\n";
- cin.getline(name, 20);
+ getline(cin, name);
cout << name;
- free(name);
system("pause");
return 0;
}