#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void vowel(fstream a){
char ch;
int ctr = 0;
while(!a.eof()){
a.get(ch);
if (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U'){
cout << ch;
ctr++;
}
}
cout << "Number of Vowels: " << ctr;
}
main(){
fstream a;
a.open("temp.txt", ios::in);
vowel(a);
return 0;
}
In this simple program , I am trying t count the number of caps Vowels in the file temp.txt. However, I am getting the error:
ios::ios(ios &) is not accessible in function fstream::fstream(fstream&)
Instead opening the file in the function itself does the job. Why is it so? Thanks a lot
NB:
How do I use fstream (specifically ofstream) through a functions parameters
Here it says, that it should work the way I am trying.
Rick
See Question&Answers more detail:os