c++ - How t solve "Variable 'std::ifstream myfile' has initializer but incomplete type" -
i create programme record of grades of students , determine it's position in frequency distribution table. records coming file. here code:
#inlcude<fstream> #include<iostream> #include<string> #include<cstdlib> using namespace std; int const ns=40; int main() { int y,x,i,vl=0,l=0,m=0,h=0,vh=0; int argr[ns]; ifstream myfile ( "file.txt", ios::in); if (myfile.is_open()) { while(getline(myfile,x)) for(i=0;i<ns;i++) { argr[i]=x; if(argr[i]<=20 && argr[i]>=0) vl=vl+1; else if(argr[i]<=40 && argr[i]>=21) l=l+1; else if(argr[i]<=60 && argr[i]>=41) m=m+1; else if(argr[i]<=80 && argr[i]>=61) h=h+1; else if(argr[i]<100 && argr[i]>=81) vh=vh+1; cout<<"range\t\tfrequency\n\n"; cout<<"0-20\t\t "<<vl<<endl; cout<<"21-40\t\t "<<l<<endl; cout<<"41-60\t\t "<<m<<endl; cout<<"61-80\t\t "<<h<<endl; cout<<"81-100\t\t "<<vh<<endl; } myfile.close(); } else cout<<"can't find file"; homecoming 0; }
another problem showed saying, "invalud preprocessing directive#include"
what should do?
#inlcude<fstream>
change to
#include<fstream>
you got typo kind of terrible ide using not show immediately?
c++ string c++11 fstream
No comments:
Post a Comment