//Declare a structure for the record
int main (int argc, char *argv)
int userinputnumber = atoi(argv);
string input;//to hold file input
Info studentstuff; // to hold info about studen
//open the file for input in binarymode
fstream student("./student.txt",ios::in); //file stream object
//if the file was sucessfully opened continue
//read an item usining ' ' as a delimiter
getline(student, input , ' ');
//store the last item read
studentstuff.studentnumber = userinputnumber;
if(userinputnumber == studentstuff.studentnumber)
studentstuff.lastname = input;
studentstuff.firstname = input;
studentstuff.major = input;
cout <<"ERROR: Cannot open file.\n";
here is the student.txt file
1 2 3 4 5 6 7 8 9 10
444444444 Adams Sally CS FR
333222111 Samuels Ann EE SO
111222333 Charels Don CS SO
666666666 Daniels Tom UN JU
777766666 Williams Al CE SE
555555555 Adams Sally EE FR
333333333 Nelson Mary CS SO
777777777 Dinh Tran MA JU
888888888 Galvez Mara UN SE
009999888 Martin Dan CS FR
in my own words my program starts by taking the commandline argument and giving it an int value. then compares that value with the first line from the .txt file. if it matches it then displays the rest of that line. maybe i've been yelling at my computer and need a break.
Looks fine to me. Are you accessing the .exe manually through the cmd (which you should for argv arguments) or are you building/running it through your IDE (which will cause a nasty error at startup since line 22 would be attempting to put an undefined element of argv into userinputnumber [perhaps this is a good place to check to see that there actually is an argument passed from cmd?])?
Oh, also, you'll have to have a while loop from line 29 instead of 'if' because as is, only the very first line will be read through ie: "444444444 Adams Sally CS FR".
1 last thing. You could take advantage of the formatting and use student >> studentstuff.firstname; instead of getline to make things cleaner.