Logically illogical

I am making a program to read bowlers names & scores from a txt file, and then print them out as a table like: name score score score
name score score score
name score ..... etc....

can someone smart please help me with this code?

#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <sstream>
#include <time.h>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
int count = 0;
int nmcnt = 0;
int scrcnt = 0;
string line;
string bowlers [11];
int score [11][3];

ifstream myfile;
myfile.open("IN.txt",ios::in);
if(!myfile)
{
cout<<"Can not open input file"<<endl;
system("PAUSE");
return 1;
}

if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
if(isalpha(line[1]))
{
bowlers[nmcnt]=line;
nmcnt++;
}
if(isdigit(line[1]))
{
if(scrcnt<3)
{
cin>>score[nmcnt][scrcnt];
}
else scrcnt=0;
}
}
}
myfile.close();
nmcnt=0;
scrcnt=0;
while(count!=11)
{
cout<<bowlers[nmcnt]<<setw(4);
nmcnt++;
count++;
for(scrcnt = 0, scrcnt!=3,scrcnt++)
{
cout<<score[nmcnt][scrcnt]<<setw(4)<<scrcnt++<<score[nmcnt][scrcnt];
cout<<setw(4)<<scrcnt++<<score[nmcnt][scrcnt]<<scrcnt=0;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}

its sloppy I know. My brain is giving up on me as ive been starting at the computer screen all day three days in a row. PLEASE AND THANK YOU IF YOU DO HELP.
A couple of errors in your code:
 
for(scrcnt = 0, scrcnt!=3,scrcnt++)

The correct separator is ; not ,
 
cout<<setw(4)<<scrcnt++<<score[nmcnt][scrcnt]<<scrcnt=0;

What are you trying to do with the =0 at the end of the line? Remove it.


PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.

Last edited on
Topic archived. No new replies allowed.