Writing input to a string

Why does the following code return an error at runtime?


#include <iostream>
using namespace std;

int main()
{
char *filename;

out << "Enter filename: ";
cin >> filename;
cout << "\nfilename is: " << filename << endl;

system("pause");

return 0;
}
first of all there is 'c' missing in the line 3 of main function
and the character u used is pointer variable
the correct code would be
#include <iostream>
using namespace std;

int main()
{
char filename[10];

cout << "Enter filename: ";
cin >> filename;
cout << "\nfilename is: " << filename << endl;

system("pause");

return 0;
}
Topic archived. No new replies allowed.