Hello World!
I have a file stream called "src" and I am reading in lines from that file. The file contains information about sms messages. The very first line tells us, how many messages are stored in the file. Then, every message takes up two lines: the first line containing information about the date of reception and the sender, the second line containing the message itself, with a length of 100 chars at maximum. The file contains 30 messages, thus it is 60+1 lines long. My task is, to tell which message is the shortest, and which one is the longest. I have started with this code:
Code:
...includes...
...var declarations...
char shortest_msg[100];
char longest_msg[100];
...some code...
...even more code...
for(i=0;i<=number_of_msg*2;i++){
fgets(current_line,100,src);
if(i==0)
continue;
else if(i/2==0){
}
else if(i/2==1){
if(strlen(shortest_msg)>strlen(current_line))
shortest_msg=current_line;
else if(strlen(longest_msg)<strlen(current_line))
shortest_msg=current_line;
}
}
I am trying to assign a character array returned by fgets() to another character array. Both of them are of the same length, 100 chars. The compiler keeps telling me, that there is an "invalid lvalue assignment". What am I doing wrong?