onemic
onemic

Reputation: 59

function wont take user input, skips getline

My function is supposed to take user input in a temporary character array before validating it and copying it into a classes data member. Problem is, whenever the program reaches getline, it seems to ignore it and go to the end of the function definition. Not exactly sure why it's acting like this.

Upvotes: 0

Views: 80

Answers (2)

nico
nico

Reputation: 1406

You are probably getting this error due your assign operation at your if statement.

if (desc[0] = '\0') {

should be:

    if (desc[0] == '\0') {
         //do your code here
}

Upvotes: 1

onemic
onemic

Reputation: 59

Adding is.ignore() before the call to is.getline(desc, 61) fixes the problem

Upvotes: 0

Related Questions