Answer the question
In order to leave comments, you need to log in
Why is the file not being read correctly?
class-header.h
#include <string>
#include <vector>
#include <fstream>
using namespace std;
typedef string str;
class User
{
public: / /в private хранятся переменные, которые никак не относятся где делу, поэтому я опустил их
vector<str> readFile()
{
vector<str> array{};
array.resize(10);
for (short x = 0; x < 10; ++x)
{
str y;
switch (x)
{
case (0):
y = "0";
break;
case (1):
y = "1";
break;
case (2):
y = "2";
break;
case (3):
y = "3";
break;
case (4):
y = "4";
break;
case (5):
y = "5";
break;
case (6):
y = "6";
break;
case (7):
y = "7";
break;
case (8):
y = "8";
break;
case (9):
y = "9";
break;
}
str path = "Saves/Users/" + m_strID + y + ".txt";
fstream file(path);
getline(file, array[x]);
cout << array[x];
file.close();
}
return array;
}
#include <iostream>
#include <vector>
#include <string>
#include "class-header.h"
int main()
{
vector<string> v = user1.readFile()
for (string elem : v)
cout << elem;
}
Answer the question
In order to leave comments, you need to log in
int main
{
...
cin.get();
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question