Results 1 to 2 of 2

Thread: Searching Files

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2002
    Posts
    21

    Searching Files

    I've looked everywhere and havent been able to find a solution. I have a file that holds the account number and the balance of the account. I want the user to enter the account number and the program tests to see if it is there and returns the balnace. I have tried figuring this out using text files and binary files but havent been able to figure it out yet

    Any help would be greatly appreciated.

  2. #2
    jim mcnamara
    Guest
    Try:
    Code:
    #include <string.h>
    #include <stdio.h>
    
    int findinfile(char *lookforme){
           FILE *in;
           int i,found;
           char *big;
           in=fopen("filename","rb")
           fseek(in,0,SEEK_END);
           i=(int) ftell(in);
           big = calloc(1+i,1);
           fread(big,i,1,in);
           found =0;
           if (strstr(big,lookforme) != NULL)
              found = 1;
           fclose(in);
           return found;
    
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width