Thread: File update with fseek and printf an arr of strutc.

  1. #16
    Registered User
    Join Date
    Jan 2012
    Posts
    29
    In another part of my code which You can't see, there is a edition tool. It bases on strcmp(). Actually it's like line 55, but it goes this:
    Code:
    printf("What is the tiitle of the book?\n");
    fgets(tmp,50,stdin);
    for(a=0;a<50;a++)
          if(strcmp(base[a].title,tmp)==0)
         {
             edition bla bla
         }
    So after removing '\n' it will crash won't it? Beacause I will have to compare: 'TITLE\0' vs 'TITLE\0\n' right?

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You should really learn how to get the string you want from the user before you start worrying about the rest of your program.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File I/O: Offsetting file pointer (fp) using fseek
    By yesyesyes in forum C Programming
    Replies: 5
    Last Post: 03-21-2011, 05:33 PM
  2. Tailing a file, fseek help
    By drshmoo in forum C Programming
    Replies: 1
    Last Post: 03-18-2011, 10:43 AM
  3. Update a file in C
    By flyjason in forum C Programming
    Replies: 2
    Last Post: 06-06-2007, 03:43 PM
  4. c script help to read a file & update
    By indy in forum C Programming
    Replies: 8
    Last Post: 12-01-2003, 11:32 AM
  5. file index update error
    By daluu in forum C Programming
    Replies: 1
    Last Post: 04-28-2003, 02:47 AM

Tags for this Thread