-
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.
-
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;
}