My request is fairly simple, although Im sure the answer is somewhere in one of the thousands of threads I just havent located yet but here goes. I am designing a program a bit like notpad except with a few more capabilities (i.e. deleting/renaming entire programs and such). All of the major functions except for "writing to file" have been completed. I can write to files, but I can only write one string to a file. For example if I were to Write "Hello_World" to a file it displays the entire thing in the text file, however, when I input it as "Hello Word" it only writes Hello to the file. Here is my code for the "write to file" function:
---------------------------------------------------------------------------------Code:#include <stdio.h>
main()
{
FILE *file;
char input[80];
char filename[]="test1.txt;
printf ("Opening %s.\n",filename);
if ((file=fopen(filename,"r+"))==NULL)
{
printf ("Unable to open specified file.\n");
return 0;
}
else
{
scanf ("%s",input);
fputs (input,file);
}
fclose(file)
}
Granted this isnt the entire code for the function, just the important parts. The part in red is where I am having trouble. I know that fputs() is used to write one string at a time but I have seen it be done where you could input what I suppose you would call two strings, or rather I have seen the opposite where you can read multiple strings at a time from a file such as "Hello" "World". I have fail to bring out the reverse outcome so I am asking for help. :confused: