pull out data frm a text file based on a condition

This is a discussion on pull out data frm a text file based on a condition within the C Programming forums, part of the General Programming Boards category; Vart, I tried again..but it doesnt give me any output... as in it shld give me "Data Found" rite when ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    I dunno wut da ya min byzed
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Page 2 of 2 FirstFirst 12
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, 01:44 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  4. Replies: 1
    Last Post: 09-10-2005, 07:02 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 04:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21