Whats wrong with this code?
Feb 14, 2015 at 1:11am UTC
Anyone?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
ifstream inputFile;
string name;
inputFile.open("filename.dat" );
inputFile >> name;
inputFile.close();
cout<<name<<endl;
return 0;
}
Feb 14, 2015 at 1:14am UTC
You ask the question that we are supposed to ask you.
Why do you think something is wrong with this code?
Feb 14, 2015 at 1:16am UTC
I have no clue that is why I am asking. It looks right to me and will not run
Feb 14, 2015 at 1:19am UTC
What do you mean by "will not run"? The code compiles and runs successfully for me.
Feb 14, 2015 at 1:21am UTC
When I go 2 debug it I get this error Native' has exited with code 0 (0x0)
Feb 14, 2015 at 1:22am UTC
That's not an error, that's a success. Your program ran so quickly that you didn't even get a chance to see it before it successfully finished and exited.
If you want your program to stop before it ends, read the first two posts here:
http://www.cplusplus.com/forum/beginner/1988/
Feb 14, 2015 at 1:24am UTC
lol, Thank you
Topic archived. No new replies allowed.