Category : fstream

I can’t find a word from the contents of the lib.txt file the word is #9577, I want to find that word. An example line: #9577*20/07/2019*234* This my code. I cant find #9577 form lib.txt. void SearchData() { string line = ""; string date = ""; string id = ""; string qty = ""; string ..

Read more

I’m using GeeksForGeeks ReadCSV function to read CSV files, I copied the code exactly as it is and I get this error: "no instance of "getline" matches the argument list" can anyone provide me with why it happens? Here’s the full code: void ReadCSV(std::string filename, std::vector<RowVector*>& data) { data.clear(); std::ifstream file(filename); std::string line, word; // ..

Read more

im about to code a small application for myself. I have a code prepared. It looks something like this. ifstream file("input.txt"); if (file.is_open()) { string myArray[5]; for (int i = 0; i < 5; ++i) { file >> myArray[i]; } cout << myArray; } Can somebody say how to get the words from the input.txt ..

Read more

for (int x = listPos.size() – 1; x != -1; –x) { iFile.seekg(listPos[x]); iFile >> word; std::cout << listPos[x] << std::endl; std::cout << iFile.tellg() << std::endl; std::cout << word << std::endl; strings.emplace_back(word); } for some reason, the cout for "listPos[x]" are all usual (i think), but once i transfer the streampos values to the ifstream ..

Read more

if (iFile >> line) { listPos.emplace_back(iFile.tellg()); } for (int x = listPos.size() – 1; x != -1; –x) { iFile.seekg(listPos[x]); std::cout << listPos[x] << std::endl; std::cout << iFile.tellg() << std::endl; } For some reason, the cout for listPos[x] are all usual (I think), but once I transfer the streampos values to the ifstream iFile, they ..

Read more

I feel like I’m completely missing out on something but my compiler shows absolutely nothing when i test out if my array is getting filled with values from the txt file. void orderID(){ ifstream result; int flag; int loop = 0; string temp; string line; string myArray[flag]; result.open("resultat.txt"); while(getline(result, line)){ flag++; //number of lines in ..

Read more

When I run this code while my "FileOutput" is open it doesn’t show the text inside the file it also outputted "yes". Why it can not change the file when it is open? int main() { ofstream something ("FileOutput.txt"); if (something.is_open()) { cout << "yes"; } something << "Hello World"; } Source: Windows Que..

Read more