0
How to use files like arrays in c OR, how to properly handle files in c ?
Unlike array, if we compare a character in a file with a char variable,(using fgetc) it also increments the pointer position. How to compare, like an array , without incrementing the position ? Also, How to know the value of a position in the file like we could use *arrayname[position] for an array ? solutions I don't want to use and reasons : Copy the file into an array - uses more memory. Decrement 1 position everytime after incrementing with fgetc - less efficient.
3 odpowiedzi
+ 1
Coder Kitten Thanks.
Is there any function which returns a character, like fgetc, but doesn't change the pointer ?
+ 1
Coder Kitten So , are comparisons and other operations done by reading them first into memory ?
I am actually trying to make a program which works like this :
"grep -o 'characters[[:alnum:]]*' filename"
on linux
+ 1
Thank you !