Ask coding questions

← Back to all posts
Input is automatically bypassed and "no" string not recognized
Thundrstruck87 (2)

Hey everyone, I'm having a couple weird issues with my code that I can't figure out - so I would appreciate if I can get any help. I've started to learn C++ so I apologize if it's something simple I am missing.

From the photo and code, I have a couple cout and cin lines (lines 65 and 67) that work as intended up until "Year". For some reason that is automatically bypassed and you can't put anything in, where as the other input fields you can. I was able to type in a year (1990, or 2012 for example) if it behaved, but it feels like enter on my keyboard is hit twice and moves to the next line. However, I tried two different IDE's, and two different computers with the same issue, so something is weird with the code.

The other problem I am having is "no" is not recognized for some reason? Example would be the "NewCustomer()" function and the if statement where the "no" is. It returns the "bash: no: command not found" error message.

Thank you for the help!

Answered by Kai_Justice (260) [earned 5 cycles]
View Answer
Kai_Justice (260)

Though I don't know much about cpp I know that the readstream cin can't assign its output to integers, I recommend doing something like this; changes are on lines 88-90.

Thundrstruck87 (2)

@Kai_Justice I appreciate it! I made the changes and I think we're getting closer. However when running it I get this. So I'm not sure if I'm missing something? I did at #include <string> at the top, but maybe C++ doesn't like this conversion.

Thundrstruck87 (2)

@Kai_Justice Nevermind that worked! I forgot to change "int Year" to "string Year" and that made it work - I appreciate the help!!

JacobMcPherson1 (237)

your getting the "bash: no: command not found" error because the program is ending before you can answer the yes/no question

JacobMcPherson1 (237)

also, I probably wont be able to help with the other stuff because I'm not that good at C++

Thundrstruck87 (2)

@JacobMcPherson1 Yeah I figured so 😄. I appreciate your help anyways!

Thundrstruck87 (2)

I just realized the "int Year;" is not a function, I moved that up under the variables section to clean up the code a bit.