FILE *fp;
fp = fopen("D:\data.txt", "r+t");
if (fp == NULL)
{
cout << "File Error" << endl;
}
else
{
char ch;
int a, e, i, o, u;
a = e = i = o = u = 0;
while (!feof(fp))
{
ch = fgetc(fp);
if (ch == 'a')a++;
if (ch == 'e')e++;
if (ch == 'i')i++;
if (ch == 'o')o++;
if (ch == 'u')u++;
}
cout << "a = " << a << endl;
cout << "e = " << e << endl;
cout << "i = " << i << endl;
cout << "o = " << o << endl;
cout << "u = " << u << endl;
fclose(fp);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น