L
Les Coover
I have struggled and struggled with this and still can not get it.
The endless loop is supposed to be that way so that
strings can be entered over and over again. When finished
CTRL + C returns to UNIX $ prompt. I know this is crude
but I am just trying to get the basics. All I want to do
is enter data into a text file, the following code compiles
and runs, creating a text file, but will not place the input 01_green
into the text file.
Thanks in advance for any help.
/* jeto.c */
#include <stdio.h>
int main(void)
{
FILE *file; /* FILE pointer */
char color[100];
/* create a file for writing */
file = fopen ("jeto.txt", "w");
printf("Enter, Example: 01_green\n\n");
while(scanf("%99s",color)== 1)
{
fprintf(file, " %50s\n", color);
}
fclose(file); /* now close the file */
return 0;
}
The endless loop is supposed to be that way so that
strings can be entered over and over again. When finished
CTRL + C returns to UNIX $ prompt. I know this is crude
but I am just trying to get the basics. All I want to do
is enter data into a text file, the following code compiles
and runs, creating a text file, but will not place the input 01_green
into the text file.
Thanks in advance for any help.
/* jeto.c */
#include <stdio.h>
int main(void)
{
FILE *file; /* FILE pointer */
char color[100];
/* create a file for writing */
file = fopen ("jeto.txt", "w");
printf("Enter, Example: 01_green\n\n");
while(scanf("%99s",color)== 1)
{
fprintf(file, " %50s\n", color);
}
fclose(file); /* now close the file */
return 0;
}