Wie öffne ich eine .txt Datei in C++?

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main () {
  string line;
  ifstream myfile("hey.txt");

  myfile >> line;
  cout << line;
  system("pause");
  return 0;
}

Warum kann diese nicht ausdrucken, was in meinen "hey.txt" Datei?

  • Sie haben zu prüfen, den Zustand der myfile. Zum Beispiel, wenn Sie die Datei gefunden hey.txt zu öffnen.
  • Und ob das Lesen erfolgreich war.
InformationsquelleAutor user2464737 | 2013-06-07
Schreibe einen Kommentar