Basically I am asked to reinvent the wheel a.k.a. the uniq commmand. I have to write a code that returns the number of occurence of each line in a file. I've done it a lot of times in Python and Java with a simple
for line in file
if given_line == line;
count += 1
but I am starting to think that there is no magic thing as
for...in...
in C. I know how to get the total number of lines with
while (!feof(f)){
fgets(line, sizeof(line), f);
count += 1;
{
So I am very much confused. I simply want to figure it out now so I will not be stuck on such a newbie problem in the future. Thanks to everybody in advance.