I am trying to learn C. :) however I am getting this error which I do not understand . Can somebody please explain this to me. I am not able to understand what is causing this issue.
#include<stdio.h>
#include<conio.h>
main()
{
FILE *fp, *ft;
char ch;
fp=fopen("D:\Documents\sample.txt","w");
if (fp ==NULL)
{
puts("cannot open file");
exit();
}
ft=fopen("D:\Documents\sample - Copy.txt","w");
if (ft ==NULL)
{
puts("cannot open file");
exit();
}
while(1)
{
ch=fgetc(fp);
if (ch== EOF)
break;
else
fputc(ch,ft);
}
fclose(fp);
fclose(ft);
}
Error message I am getting :-
C:\Users\LoneRanger\Desktop\FileHandling.c: In function 'main':
C:\Users\LoneRanger\Desktop\FileHandling.c:8:11: warning: unknown escape sequenc
e: '\D' [enabled by default]
fp=fopen("D:\Documents\sample.txt","w");
^
C:\Users\LoneRanger\Desktop\FileHandling.c:8:11: warning: unknown escape sequenc
e: '\s' [enabled by default]
C:\Users\LoneRanger\Desktop\FileHandling.c:12:6: warning: incompatible implicit
declaration of built-in function 'exit' [enabled by default]
exit();
^
C:\Users\LoneRanger\Desktop\FileHandling.c:12:6: error: too few arguments to fun
ction 'exit'
C:\Users\LoneRanger\Desktop\FileHandling.c:15:11: warning: unknown escape sequen
ce: '\D' [enabled by default]
ft=fopen("D:\Documents\sample - Copy.txt","w");
^
C:\Users\LoneRanger\Desktop\FileHandling.c:15:11: warning: unknown escape sequen
ce: '\s' [enabled by default]
C:\Users\LoneRanger\Desktop\FileHandling.c:19:6: warning: incompatible implicit
declaration of built-in function 'exit' [enabled by default]
exit();
^
C:\Users\LoneRanger\Desktop\FileHandling.c:19:6: error: too few arguments to fun
ction 'exit'
C:\Users\LoneRanger\Desktop>gcc C:\Users\LoneRanger\Desktop\FileHandling.c -o Fi
leHandling
C:\Users\LoneRanger\Desktop\FileHandling.c: In function 'main':
C:\Users\LoneRanger\Desktop\FileHandling.c:8:11: warning: unknown escape sequenc
e: '\D' [enabled by default]
fp=fopen("D:/\Documents/\sample.txt","w");
^
C:\Users\LoneRanger\Desktop\FileHandling.c:8:11: warning: unknown escape sequenc
e: '\s' [enabled by default]
C:\Users\LoneRanger\Desktop\FileHandling.c:12:6: warning: incompatible implicit
declaration of built-in function 'exit' [enabled by default]
exit();
^
C:\Users\LoneRanger\Desktop\FileHandling.c:12:6: error: too few arguments to fun
ction 'exit'
C:\Users\LoneRanger\Desktop\FileHandling.c:15:11: warning: unknown escape sequen
ce: '\D' [enabled by default]
ft=fopen("D:/\Documents/\sample - Copy.txt","w");
^
C:\Users\LoneRanger\Desktop\FileHandling.c:15:11: warning: unknown escape sequen
ce: '\s' [enabled by default]
C:\Users\LoneRanger\Desktop\FileHandling.c:19:6: warning: incompatible implicit
declaration of built-in function 'exit' [enabled by default]
exit();
^
C:\Users\LoneRanger\Desktop\FileHandling.c:19:6: error: too few arguments to fun
ction 'exit'