There is a file in directory and i’m trying to read a file but i can’t. What is wrong with my code. Example is taken from http://www.cplusplus.com/forum/beginner/37208/
#include <iostream>
#include <fstream>
#include <string>
#define MAX_LEN 100
using namespace std;
string inlasning ()
{
string text;
string temp; // Added this line
ifstream file;
file.open ("D:\education\Third course\semestr 2\security\lab1.2\secret_msg.txt");
while (!file.eof())
{
getline (file, temp);
text.append (temp); // Added this line
}
cout << "THE FILE, FOR TESTING:\n" // For testing
<< text << "\n";
file.close();
return text;
}
void main ()
{
inlasning();
}
Change
\to\\in file path. (or to/)