+ 14

Best alternative for scanf to avoid buffer overflow?? What's wrong with this.... How do I prompt user of inputted space or char

When I type invalid input... It displays enter a valid input... But doesn't take the input... Why is so can someone help..? https://code.sololearn.com/c28bJ5t1fW0K/?ref=app

23rd Apr 2020, 9:12 AM
The CodeGeek
The CodeGeek - avatar
28 Respostas
+ 6
Ohk I will try it tnx
23rd Apr 2020, 9:26 AM
The CodeGeek
The CodeGeek - avatar
+ 6
Tnx Aman but still I have to fix some issues such as inputting space then user should be promoted etc
25th Apr 2020, 5:17 AM
The CodeGeek
The CodeGeek - avatar
+ 5
What if I want to enter wrong input twice it as many times then it is not working just input and see 10 9 6
23rd Apr 2020, 9:50 AM
The CodeGeek
The CodeGeek - avatar
+ 5
Also spaces aren't counted at all ..
23rd Apr 2020, 9:51 AM
The CodeGeek
The CodeGeek - avatar
+ 5
ChaoticDawg do u mean a do while loop ... But I tried it and it gives Enter a valid input and doesn't print the pattern
23rd Apr 2020, 5:10 PM
The CodeGeek
The CodeGeek - avatar
+ 5
Tnx man u helped me
23rd Apr 2020, 6:14 PM
The CodeGeek
The CodeGeek - avatar
+ 5
Tnx everyone šŸ‘
24th Apr 2020, 5:11 PM
The CodeGeek
The CodeGeek - avatar
+ 5
Jude img src tag
25th Apr 2020, 4:05 AM
The CodeGeek
The CodeGeek - avatar
+ 5
Tnx
25th Apr 2020, 8:38 AM
The CodeGeek
The CodeGeek - avatar
+ 4
Enter both at the same time when the playground asks for your input like: 10 6
23rd Apr 2020, 9:22 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
Made a few slight modifications to your code so it will loop until valid entry etc. https://code.sololearn.com/cQDlwTa1KQ1S/?ref=app
23rd Apr 2020, 6:11 PM
ChaoticDawg
ChaoticDawg - avatar
+ 4
So Stephen what should I use instead of scanf
24th Apr 2020, 5:02 PM
The CodeGeek
The CodeGeek - avatar
+ 4
To take input??
24th Apr 2020, 5:06 PM
The CodeGeek
The CodeGeek - avatar
+ 4
Also u have to specify it's width and height so to avoid problems
25th Apr 2020, 4:06 AM
The CodeGeek
The CodeGeek - avatar
+ 4
Ok tnx
12th May 2020, 2:43 PM
The CodeGeek
The CodeGeek - avatar
+ 4
Tnx
12th May 2020, 3:38 PM
The CodeGeek
The CodeGeek - avatar
+ 3
You are having input problems You have to give all your inputs at once like : 9 6 and enter Sololearn playground works like this only :)
23rd Apr 2020, 9:23 AM
Daljeet Singh
Daljeet Singh - avatar
+ 3
Yup the solution to the problem by Daljeet Singh and ChaoticDawg is right. You just need to enter both the values at the same time either with a space or an enter. Then you can press submit to get the correct output.
23rd Apr 2020, 9:49 AM
Tanmay Gupta
Tanmay Gupta - avatar
+ 3
Prathik Shetty you aren't looping over that part of your code. If that's what you want to do then you'd need to wrap your code in a loop that exits the loop when a valid entry is made.
23rd Apr 2020, 4:52 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Nice
24th Apr 2020, 1:33 AM
Favour
Favour - avatar