Thread: pull out data frm a text file based on a condition

  1. #16
    Registered User
    Join Date
    Nov 2006
    Posts
    13
    Vart,

    I tried again..but it doesnt give me any output... as in it shld give me "Data Found" rite when task = venor setup........ dunno whr exactly am goin wrong

  2. #17
    Registered User
    Join Date
    Nov 2006
    Posts
    13
    shld i use fsprintf or fprintf ????? also cud u tel me the difference between the two !!!!

  3. #18
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by nirmala.s
    dunno whr exactly am goin wrong
    post your last code

    shld i use fsprintf or fprintf ????? also cud u tel me the difference between the two !!!!
    No, I couldn't - never heared about the first one
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #19
    Registered User
    Join Date
    Nov 2006
    Posts
    13
    my last code:

    Code:
    # include <stdio.h>
    # include <stdlib.h>
    # include <string.h>
     
    int main()
    {
      FILE *in_file;
      char dataFile[20];
      char date[20];
      char operator[30];
      char ts[80];
     
      printf("&#203;nter file name");
      scanf ("%s", dataFile);
     
      in_file = fopen(dataFile, "r");
     
      fsprintf(in_file, "%s%s", date, operator);
      fgets(ts,sizeof(ts), in_file);
     
     
      if ( strstr(ts,"Vendor Setup") != NULL)
      
       {
          printf("Data found");
       }
      
       return 0;
    }

  5. #20
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    1. you' still using in_file without check
    2. you're using date and operator without initialization
    3.you're not checking the result value of fgets
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #21
    Registered User
    Join Date
    Nov 2006
    Posts
    13
    am sorry..i dunno how 2 go abt wht u say !!! can u help me ??? diz is my first in C...am just on the learnin curve !!! it mite sound silly but then, vent worked on C much, so findin it difficult as in am learnin one by one n tryin them out 2 get it goin !! Cud u help in lettin me knw wht changes i need 2 make ???

  7. #22
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    I dunno wut da ya min byzed
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Replies: 1
    Last Post: 09-10-2005, 06:02 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM