When I run my code on Clion I dont get this error. But when i run my code on my school's dev server, I realize every line size except the last line in my file below has a size line.size()+1.
This is my file
6
5 8 2 5 6 7
5 4 7 3 2 1
2 5 3 4 7 5
6 5 8 7 2 3
6 4 3 1 1 2
2 7 8 2 1 6
2 1
1 2
2 4
4 0
5 3
2 2
It reads first line size as 2 etc. It reads every line size as size +1 except last line.
And this is my code.
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
int num;
vector <vector <int> >board;
int points = 0;
int main(int argc, char **argv) {
string file_name_2 ;
vv << argv[2];
vv >> file_name_2;
stringstream vd;
fstream myFile;
myFile.open(file_name_2, ios::in);
if (myFile.is_open()) {
string line;
int index = 0;
while(getline(myFile, line)){
if (line.size()== 1 || line.size()==2 || line == "100"){
stringstream zz;
zz << line;
zz >> num;
.
.
.
I am using getline(file_name, line)
to read lines.
What causes this and how can i fix it?