cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Writing input to a string
Writing input to a string
Feb 26, 2010 at 5:03pm UTC
dp5000
(1)
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;
}
Feb 26, 2010 at 6:24pm UTC
amit0991
(12)
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.