Thread: File problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    zach
    Guest

    File problem

    Code:
    FILE *fp;
        char *p;
        char str[35];
        int counter = 0;
        
        fp = fopen("data5.txt","r");
        if(fp == NULL)
        {
            gotoxy(70,5);
            puts("No data5.txt with codes.");
        }    
    
        while(fgets(str,35,fp)!= NULL)
        {
            if(lineNo[counter + 1] == 1)
            {
                gotoxy(30,counter + 4);
                puts(str);//  ***
            }
            counter++;
        } 
        fclose (fp);


    This *** printing should take place when lineNo[counter + 1] == 1 which it does correctly but when lineNo[counter + 1] == 0 a new line is being printed and that is unintended. Please help. Zach K.
    Last edited by zach; 09-28-2019 at 06:26 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File handing and saving records to file problem
    By loveable in forum C Programming
    Replies: 18
    Last Post: 12-29-2012, 09:53 AM
  2. file input and file pointer problem
    By drater in forum C Programming
    Replies: 6
    Last Post: 02-18-2008, 10:43 AM
  3. Replies: 3
    Last Post: 11-21-2006, 07:26 PM
  4. Replies: 3
    Last Post: 10-20-2006, 07:59 PM
  5. Replies: 3
    Last Post: 05-03-2003, 12:04 PM

Tags for this Thread