I have no idea why the following code doesn't open the file "blueprint.txt" (which is in the same directory as the source code). The code compiles fine, but returns the error message. Ive tried changing the code to
ifstream file("blueprint.txt");
OR
ifstream file;
file.open("blueprint.txt", ios::in);
OR
ifstream file;
file.open("blueprint.txt");
All to no avail. This is a simple process and I'm at a loss as to why its giving me trouble.
This is obviously aimed at the education where Apple has lost so much ground to Chromebooks in the last few years, but unless they come up with a comparable management system for education why would anyone switch back?
MSN defined our generation in some ways, kind of like Snapchat and TikTok have done for future generations.
I have great memories of the MSN era in the late 90s / early 2000s. In the UK everyone seemed to come home from School and go on MSN for the evening. We didn't really have mobile phones then, so other than going and knocking on your friends door it was a totally new way of interacting with people. I also loved how I could talk to people I’d met playing online games from around the world.
Inviting people to NetMeeting and messing about with the shared white board and webcams was pretty fun, even if webcams only ran at a couple of fps over dial-up.
All the random things you could do with MsgPlus! were really fun - I suspect that made a few people jump with /shello randomly blasting Mr Hankey out their speakers!
Maybe I’m just nostalgic, however I do feel the internet and computers were more fun back then.
Question
TyRanniKaL
I have no idea why the following code doesn't open the file "blueprint.txt" (which is in the same directory as the source code). The code compiles fine, but returns the error message. Ive tried changing the code to
ifstream file("blueprint.txt");
OR
ifstream file;
file.open("blueprint.txt", ios::in);
OR
ifstream file;
file.open("blueprint.txt");
All to no avail. This is a simple process and I'm at a loss as to why its giving me trouble.
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream file("blueprint.txt", ios::in);
if (!file.good()) {
cerr << "Can't open file " << endl;
} else {
cout << "File opened." << endl;
}
return 0;
}
Thanks in advance.
Link to comment
https://www.neowin.net/forum/topic/681360-c-cant-open-files/Share on other sites
3 answers to this question
Recommended Posts