Hi, I am working with structures for the first time. I am not able to cout the data I read from a file using a struct. My program is below. What am I doing wrong?
I learned it in class. I asked the prof about it and he said you can use void main when you want to be lazy and not write return 0;
Ok I edited my code with int main and I changed player_info player; to player_info player[MAX_PLAYERS];
I realized I have to declare an array variable for the struct. I change this throughout the code, but now I am receiving the following error message: Unhandled exception at 0x001b1102 in Assign 5.exe: 0xC0000005: Access violation writing location 0x000000aa.
i cannot exceed MAX_PLAYERS because there are only 20 lines in the data file. I increased MAX_PLAYERS from 20 to 50 but it still does not work. I can easily debug when I have an error list. However, there is not error list. I just get a pop-up message.
Do you understand what a debugger is, and what it does? If not, I strongly recommend you find a tutorial for whichever debugger comes with your IDE, and learn how to use it. You;ll find it invaluable in finding and fixing this sort of problem.
Ok I will look into a tutorial on the debugger. I am using Microsoft Visual C++ 2010 Express as my IDE. I know you can do breakpoint and that it would help you identify the error, but all the code from the debugger is mystifying to me at this point.
The data file contains the following:
ANDERSON SF K JOANN
TIMPSON PHIL WR JIM
ELWAY DEN QB JACKV
SALAAM CHI RB BILL
CARNEY SD K VINCE
SANDERS DET RB JOHN
CARTER MINN WR JACKR
FREEMAN GB WR RON
WATTERS PHIL RB CHRIS
CHMURA GB TE STEVE
BLEDSOE NE QB CHRIS
FAULK IND RB JIM
GEORGE TENN RB STEVE
BETTIS PITT RB JACKV
STEWART PITT QB BILL
DUDLEY OAK TE JOHN
MARINO MIA QB VINCE
KIRBY SF RB RON
WARREN SEA RB JACK
MARTIN NE RB JOANN
Thanks, I understand the vectors but my professor doesn't want us to go beyond what he's taught. Is there anyway to do this with chars or just strings?