0

Where I went wrong?

This is a code coach problem.named spy life my output and the expected output are same but still it is showing an error and no test case is passed... indentation,spaces or capitalization all are fine..yet error persist.. Can anyone help me with this..?? https://code.sololearn.com/cnzBhc7hAQHZ/?ref=app Editor.:: https://www.sololearn.com/coach/55?ref=app

3rd May 2020, 4:51 AM
_/`Juju`\_
_/`Juju`\_ - avatar
9 Respostas
+ 2
Line 8: using scanf in C would fail to recognise space separated strings. Try scanf("%[^\n]%*c", a); instead Although, simply using scanf works fine if input is a single token Line 17: for(int k=strlen(O);k>=0;k--) k should start with strlen(O) - 1 You may also use (k=t)
3rd May 2020, 5:20 AM
Infinity
Infinity - avatar
+ 1
you could do it without the second loop and without o[50] by printing each char every time. there's an extra char since you are iterating with the whole strlen() should be strlen(a) - 1 ; and you didn't give yourself enough memory by limiting array size to 50. https://code.sololearn.com/cGTKdj39NWB9/?ref=app
3rd May 2020, 5:18 AM
Bahha┣
Bahha┣ - avatar
+ 1
Bahha🐧 I did something similar
3rd May 2020, 5:29 AM
Infinity
Infinity - avatar
+ 1
Infinity and Bahha🐧 thanks guys... I tried "gets" to check what kind of error I'm getting but in code coach editor there is no errors coming... Also i tried this snippets infinity, but one test case is not passing..😱 Bahha can you explain fgets fn??
3rd May 2020, 5:52 AM
_/`Juju`\_
_/`Juju`\_ - avatar
+ 1
fgets(a, MAX_SIZE, stdin); a - input variable MAX_SIZE - upper limit of length stdin - standard input
3rd May 2020, 6:01 AM
Infinity
Infinity - avatar
0
Infinity he used gets the first time, then changed it to scanf 😅
3rd May 2020, 5:28 AM
Bahha┣
Bahha┣ - avatar
0
ATSHAYA KUMAR.R may be because your array size is not enough try the code I posted.
3rd May 2020, 5:54 AM
Bahha┣
Bahha┣ - avatar
0
Try fgets(a,50,stdin);
3rd May 2020, 5:55 AM
Infinity
Infinity - avatar
0
Bahha🐧 yeah your code passed all test cases.. and Infinity yeah that fgets worked
3rd May 2020, 5:56 AM
_/`Juju`\_
_/`Juju`\_ - avatar