Reputation: 186
Here is my problem: I read from a .csv file and put every characters of such file into a 1D array of, say, 500 characters (I know that the number of characters in the .csv file won't ever reach such number, so it is fine). The thing is, I want to add a new line at the end of my .csv file. Since I need to do some operation on the characters before putting it in the file, I would like to add the content of such line at the end of my array, well, at the index before EOF. Is there an easy way to scan through my whole array and find where to put the new content?
For instance, my array would look something like this:
[ j o h n , p a s s 1 2 , u s e r (...remaining empty spaces, i.e RES) ]
[ j o h n , p a s s 1 2 , u s e r j o e y , h e l l o 9 , u s e r (RES) ]
Thanks in advance.
Upvotes: 0
Views: 166
Reputation: 51840
To seek to the end of the file, you do:
fseek(file, 0, SEEK_END);
So to seek to one position before the end of the file, you would do:
fseek(file, -1, SEEK_END);
Upvotes: 1