//Main function
void main () {
double count=0,i,stud[20],sum=0,x=0;
string inname="input.txt";
ifstream infile (inname);
ofstream outfile ("output.txt");
if (!infile && outfile) {
cout<< "There was a problem loading file "<<inname
<<"for reading."<<endl;
}
for (int k=0;k<20;k++) {
while (infile>>i) {
count++;
stud[k]=i;
cout<<"Mark of student "<<count<<" : "
<<stud[k]<<endl;
}
}
cout<<endl;
cout<<"Your mean is "<<avg(x)<<endl;
outfile<<"Your mean is "<<avg(x)<<endl;
cout<<"Your std deviation is "<<stdviation(x)<<endl;
barchart ();
cout<<endl;
system ("pause");
}
Above is my program where i need to read a sequence of marks from txt.file and calculate its mean and std deviation and then write on another txt file. I'm having problem in writing the data onto txt.files now. It's showing blank page. Can anyone tell me what gone wrong in the code above ??
Please use code tags. EDIT: You are pening your file several times in different piints in your program. Default settings will rewrite file everytime it opens.