What is the problem with this programme?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#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);
}
|
help me plzzzzz.
tell me the syntax error in this programme(if any)
when i run this programme it just displays few words half of them garbage...
need help...
#include <conio.h>
Line 24:
i=(int)fgets(file,100,th);
Damn that is ugly, unsafe code
I'd say the scanf("%s")s are far more unsafe than that >_>
I meant all of his code in general
Topic archived. No new replies allowed.