Where i should put cin.ignore() in function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Where i should put cin.ignore() in function

I have put it everywhere in "input" function, but it doesn't work well. And is there any other mistake with my programm because I couldn't check it because the first issue. Here is the code: https://code.sololearn.com/ca5A12A23a4A/?ref=app

3rd Mar 2021, 4:55 PM
Adilx01
1 Answer
+ 2
std::cin.ignore() is fine, although only discarding a single character might not always be enough. However, you forgot to include the <cstring> header, and strcpy() does not take the number of characters as argument (strcpy_s() does not appear to be available on SoloLearn). The INT_MIN macro is not defined unless you include the <climits> header, and your logic to determine the best student is incorrect, since you are mixing average marks and numbers when comparing the students. Here is a working code: https://code.sololearn.com/cnYY20fyEn9x/?ref=app
3rd Mar 2021, 6:03 PM
Shadow
Shadow - avatar