0

[SOLVED]In the below code ..I want to give value in the scanf function but it showing error..

https://code.sololearn.com/cmpdhRAINOVl/?ref=app

30th Aug 2021, 3:37 PM
THE CRAZY ONE ✌️
THE CRAZY ONE ✌️ - avatar
6 Respuestas
+ 3
Hi there, that's because dynamic input is not supported on the SL playground, you have to insert all of your input in one take by separating them with spaces.
30th Aug 2021, 3:42 PM
Maz
Maz - avatar
+ 3
Line 12: This loop will trigger an error cause it tries to go beyond the `st[]` array bound (<val> elements). The condition should be `i < val` not `i <= val`. for( int i = 0; i < val; i++ ) // correct loop condition Line 15: `std::string` value cannot be read in using scanf(). `std::string` is not char array (C-string). You need to use `std::cin` std::cin >> st[ i ]; Line 16: Undefined variable <s>. Did you mean <st>? You said you have tried getline() but I don't see it in your code ...
30th Aug 2021, 3:47 PM
Ipang
+ 2
Ipang I do getline function is my system (laptop) other than variable undeclare error.... I want to input the values
30th Aug 2021, 4:00 PM
THE CRAZY ONE ✌️
THE CRAZY ONE ✌️ - avatar
+ 1
for (int i = 0; i < val; i++) { cout << i << endl; cin >> st[i]; cout << st[i] << endl; } This will do ...
30th Aug 2021, 5:07 PM
Ipang
+ 1
Thanks Ipang
30th Aug 2021, 5:23 PM
THE CRAZY ONE ✌️
THE CRAZY ONE ✌️ - avatar
0
Maz 2 1 hello Hello 1 Hello 2 This is how input in SL and yes as u said abt input I do in vs code but it didn't work
30th Aug 2021, 3:58 PM
THE CRAZY ONE ✌️
THE CRAZY ONE ✌️ - avatar