int main(int argc, char *argv[])
{
FILE *fp;
char str[80],ch;
if((fp=fopen(argv[1],"r"))==NULL)
{
printf("cannot open the file.\n");
exit(1);
}
do
{
fgets(str,70,fp);
printf(str);
printf("\nDo you want to read more?Y/N\n");
ch=getch(); //這裡只能用getch() or getche(),一旦用getchar()則只會繼續執行一次,之後竟會自動結束程式。不知為何?
if(ch!='y') break;
}
while(!feof(fp));