top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

fgets I don't want it to return the new line char

+3 votes
781 views

I'm using fgets which will read a single line at a time, but with fgets I don't want to return the new line char (\n).
Any suggestions or alternatives?

posted Nov 6, 2014 by Harshita Dhaliwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Its simple, after calling fgets() just assing '\0' null character at the '\n' place.
Example:

1. fgets(buff, size, file_pointer);   // it will read the file and copy the entire line into buff
2. buff[strlen(buff) - 1] = '\0';     // it will replace the '\n' with '\0'.

done

answer Nov 6, 2014 by Arshad Khan
Similar Questions
0 votes

When I update my branch from master it pulls down several files, including some sass files. When I compile, however, gulp alerts me that I am missing .scss files.

I tested this by creating a new fresh branch and running gulp sass. This time there were no errors and I saw the missing .scss had been brought in.

Would anyone know why, on update, I am only getting some of the files from master?

+4 votes

I am wanting to extract variable names and their size (int, char and etc.) from a c file.
Is there any way to extract that type of information?

...