I need to write simple program in C++!
I need to write program that read information from file,which contain <50,students name and respective score.My program need to calculate average score and print out students name,who get below average mark to screen!But,i don''t know how to use string to do it....
here's sample code:
***********************************************************
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
ifstream inData;
typedef basic_string<unsigned char> ustring;
string Name;
int iNum[50],i,point,sum_score,maxIndex,highestScore;
char iName;
point =1;
sum_score=0;
int average_score;
inData.open ("C:\\Documents and Settings\\GobiV\\Desktop\\studentresult.txt");
cout<<"No Student Name Score "<<endl;
for (i=0; i<50; i++)
{
inData>>Name>>iNum;
sum_score=sum_score+iNum;
average_score=sum_score/50;
cout<<left<<setw(5)<<point++;
cout<<left<<setw(15)<<Name;
cout<<right<<setw(5)<<iNum;
cout<<setw(12);
cout<<endl;
}
maxIndex=0;
for(i=0;i<50;i++)
if(iNum[maxIndex]<iNum)
maxIndex=i;
highestScore=iNum[maxIndex];
if(iNum>average_score)
{
cout<<strcpy(iName,Name);
}
inData.close ();
cout<<right<<setw(5)<<"\n\nSum of all students score is : "<<sum_score;
cout<<right<<setw(5)<<"\n\nAverage students score is : "<<average_score;
cout<<right<<setw(5)<<"\n\nHighest Students Score is : "<<highestScore;
cout<<endl;
return 0;
}
*********************************************************
Please help me???