Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- int main()
- {
- FILE *fp, *fp2, *fp3;
- int vowel = 0, consonant = 0;
- char ch;
- char message[200];
- fp = fopen("E:\\Lab 2\\input.txt", "r");
- fp2 = fopen("E:\\Lab 2\\vowel.txt", "w");
- fp3 = fopen("E:\\Lab 2\\consonant.txt", "w");
- if (!fp)
- {
- perror("Error: ");
- exit(1);
- }
- while (!feof(fp))
- {
- fgets(message, 200, fp);
- printf("%s", message);
- }
- printf("\n\n");
- fseek(fp, 0, SEEK_SET);
- while (ch != EOF)
- {
- ch = fgetc(fp);
- if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
- {
- if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')
- {
- fputc(ch, fp2);
- vowel++;
- }
- else
- {
- fputc(ch, fp3);
- consonant++;
- }
- }
- }
- fprintf(fp2, "\nCount:%d", vowel);
- fprintf(fp3, "\nCount:%d", consonant);
- fclose(fp);
- fclose(fp2);
- fclose(fp3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement