Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Ambiguous behaviour of getline() and cin.ignore() in C++

$
0
0

Hey! I want an explaination for this scenario : Problem LINK
Solution 1

Solution 2

In soltion 1 , i'm taking no. of test cases as input through cin and then ignoring the remaining line by using cin.ignore(). This results in WA. While in Solution 2 , i'm taking the no.of test cases as input using getline and then converting it into int. This gives AC. Why is that so?? thanks in advance!


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>