Weird stuff with fd.ignore.

so i was doing an exercise and i had this text file :

6
Guolis P20 30
Riebokslis R33-25KT 12
Karbiuratorius VWG0911 5
Valytuvas APK1 7
Zvakes A25 25
Varztai M12X45 33

and for some reason when i did fd.ignore('\n', 256) it couldn't read it properly but only when the number is on 10 it reads properly, any suggestions why?
1
2
3
4
5
6
7
8
9
  char eil[24];
    fd>>n;
    for(int i=0; i<n; i++)
    {   fd.ignore('\n', 10); // i had the number on 256
        fd.get(eil, 24);
        a[i].pav= eil;
        fd>>a[i].kiek;

    }
You are passing the arguments in the wrong order. It just happens to work when you pass 10 because 10 is the ASCII code for the newline character.

http://www.cplusplus.com/reference/istream/istream/ignore/
Last edited on
woops :D, alrighty
Topic archived. No new replies allowed.