I am having a problem with input/output. I have created a text file called input.txt and want to move this to output.txt
I have been able to move a single character over with %c but when I have tried to use %s it doesn't appear to work.
This is the code I have used:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void main (void)
{
char e[30];
char temp_char;
int counter;
FILE *f_input;
FILE *f_output;
for(counter=0; counter<200; counter++)
if ((f_input = fopen("input.txt","r"))==NULL)
{
printf("Cannot open file\n");
exit(1);
}
fscanf(f_input,"%c", &temp_char[counter]);
if ((f_output = fopen("output.txt","w"))==NULL)
{
printf("Cannot open file for writing\n");
exit(1);
}
fprintf(f_output,"The input file contained the following: %c \n",temp_char);
fclose(f_input);
fclose(f_output);
getch();
}
Can anyone help, thanks if you can.