Reading in an character array from user, segmentation error?
Posted on 2003-11-24
For class we've been assigned to take a file of football players and read them into an array or structures. Everything is read in correctly, and we are to give the user the option to search through the array of structures to find a player, that is if they are in the list.
Here's what I have so far.
When this code runs, it says-
Enter the exact name to search for: Segmention Fault
Ive been using g++.
int searchName(qbInfo qbs, int numQBs, int x)
int index = 0;
bool found = false;
int count = 0;
cout << "Enter the exact name to search for: ";
cin.get(ch); //this is where the error is coming in
while(ch!= '\n') // read in until user hits enter
cin.get(ch); //going to cause the error again?
What can I do to read in the entire name, Ive tried cin >>userinput; but that is only going to read up until say the name is "Trent Green", it will only read in "Trent" and hit the space and stop.