>void main()
No, int main ( void ).
>exit();
exit must have an argument of 0, EXIT_FAILURE, or EXIT_SUCCESS to be portable. No argument is an error. You also haven't included stdlib.h.
>getch();
Not portable and you didn't include conio.h.
Here are my corrections, I switched getchar with getch for portability reasons. If you want to change back do not forget to include conio.h.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE*fp;
char s[80];
fp=fopen("poem.txt","r");
if(fp==NULL)
{
puts("cannot open the file");
exit(0);
}
while(fgets(s,79,fp)!=NULL)
printf("%s",s);
fclose(fp);
getchar();
return 0;
}
-Prelude