If I use the cin.getline(aString,int something)command the program runs well on the first time but if i restart the program by f.e. calling main for the second time, the program skips the cin.getline.
What do I have to do to solve this problem?
If I use the cin.getline(aString,int something)command the program runs well on the first time but if i restart the program by f.e. calling main for the second time, the program skips the cin.getline.
What do I have to do to solve this problem?
I was under the influence that calling main somewhere in your program was considered bad practice, anyhow.
Otherwise, I'd suggest you need to flush out your input buffer ( ::dodges Hammer:: but not using fflush!! ). Just throw in an endl somewhere after you use cin.getline.
>>I was under the influence
Been on that apple cider again Kendo
He's right though....never call main() yourself
Yes, it even yields undefined behaviour.Originally posted by -KEN-
I was under the influence that calling main somewhere in your program was considered bad practice, anyhow.
The function main shall not be used (3.2) within a program.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
>f.e. calling main for the second time
If you're allowed to do this then you're not using C++. Calling main recursively is illegal and results in a compile time error. It's allowed in C, but not a good idea.
*Cela*
getline(cin, string)Originally posted by Ivan!
If I use the cin.getline(aString,int something)command the program runs well on the first time but if i restart the program by f.e. calling main for the second time, the program skips the cin.getline.
What do I have to do to solve this problem?
should do the trick