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.
Microsoft is reportedly seeking help from its biggest cloud rival, Amazon Web Services, to address mounting capacity issues of GitHub. According to a report by Business Insider, this move of the company comes after a series of AI-driven outages on the coding platform, which Microsoft acquired in 2018. Despites its plans to migrate GitHub completely to Azure by 2027, increasing demand from AI coding tools has forced Microsoft to adopt a multi-cloud strategy...............
https://cio.economictimes.indiatimes.com/news/corporate-news/microsoft-taps-aws-for-github-capacity-amid-ai-driven-outages-and-multi-cloud-strategy/131761981
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