Блог пользователя 2017ceb1029

Автор 2017ceb1029, история, 7 лет назад, По-английски

The problem link is : B level And it passes 20 tests but fails on 21st. In an online compiler "CODE" works fine, for the same test case, by failure I mean RUNTIME_ERROR. Any help would be appreciated. The same code first failed at test case 26th, which i noticed was due to less allocated memory when I tripled the allocated space, it fails at 21st case which gives correct output in the other compiler.

Thanks

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
char* c= (char* ) malloc(sizeof(char)*len);
scanf("%s",c);

Pretty sure scanf is based on null terminated strings so you need to allocate 1 more byte.