0

Hey..
i want to make a string from a text file..
then i want to compare this string with another to see if they are the same...
any help??
/*I'm a beginner*/

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by elie_kfoury
0

Hi
You will need to create a "main" program.
fopen the filename
fgets from the file into a buffer
The buffer should be declared large enough
fclose the file
strcmp the 2 buffers of characters
printf some kind of result
Peter

0
FILE *in;
     in=fopen("file.txt","r");

int i=0;
     while(fgets(buff,BUFSIZ,in)!=NULL){
           a[i]=atof(buff);
	       i++;
     }

//do something with the stuff you've read in

fclose(in);

i'm very much a beginner too but i THINK this will get you on the lines of reading in float values. its not difficult to convert it into reading characters from the file. try googling for parts of code - don't expect to just go out and find what your looking for. you have to play around yourself too otherwise its no fun.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.