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*/

Recommended Answers

All 5 Replies

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

Thx dude
can u give an example plz??

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.

Thx duude..
works fine..

Thx duude..
works fine...:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.