Hello, I want your help in C. I have a file which contains lines with spaces. When I use printf("%s",str) it prints my data in new lines but I want to display them in a single line. Is there any way to do it? Thanks!
Sorry...
I found how to print the whole string! I used fgets and printf worked fine!
Can you help me now how to insert a string with spaces? Like: My Book 1.
I used gets but it does not work...Is there any other command to read string with spaces?
Thanks!!
Book b ;
Book* book = &b ;
// read a full line upto a maximum of 100 characters in length
// the line may contain spaces
char* p = fgets( book->title, 100, stdin ) ;
// remove the new line at the end
if(p) book->title[ strlen(p) - 1 ] = 0 ;
fgets reads a string from a file. I want to take a string with spaces from user. gets does not work and I don't know why. I want to take as input: My Book (with the space) and store it in book->title.