#include<stdio.h>
#define CR 13
#define LF 10
int main()
{
FILE *tg;
FILE *th;
FILE *printer;
int i,a;
char input[20];
char file[100];
char input2[20];
char file2[100];
printf("Enter the file name for reading : ");
scanf("%s",input);
th = fopen(input,"r");
printer = fopen("PRN","w");
do
{
i=fgets(file,100,th);
putc(i,printer);
printf("\n\n%s",file);
}while(i != EOF);
printf("Enter a file for writing to : ");
scanf("%s",input2);
tg = fopen(input2,"w");
char c;
printf("Write something : ");
do
{
c=getch();
putc(c,tg);
if( c==CR )
{
putchar(LF);
}
putchar(c);
}while(c != '~');
getchar();
fclose(tg);
fclose(th);
}
What is the problem with the above programme..
when i open a file for reading it just shows the last few words?
help .....