Guys, I got a problem in File Handling..
I entered two words(My World)to be saved in a file
but the file displays the first word only.
Can you guys help me....

here's the code:


#include<stdio.h>
#include<conio.h>
{
FILE *fp;
char name[45];
fp=fopen("c:\\file.txt","a+");
clrscr();
gotoxy(33,3);cout<<"ADD ENTRY"<<endl;
do
{
fscanf(fp,"%s",&name);
}
while(!feof(fp));
printf("Enter Name:");
scanf("%s",&name);
fprintf(fp,"%s\n",name);
getch();
fclose(fp);
}

Try using fgets to read from stdin.

char *fgets(char *s, int size, FILE *stream)

%s only stores the string till its finds its first white space.so in case where u r using %s only the first word gets stored.
to store word with white spaces use gets and fgets