why some code in sololearn run in my machine and others are not? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

why some code in sololearn run in my machine and others are not?

19th Aug 2019, 5:40 AM
oel_arimla
oel_arimla - avatar
4 ответов
+ 2
`gets` is considered unsafe as it doesn't allow us to specify maximum read buffer size (which could trigger buffer overflow) - unlike `fgets` (mentioned in tags) or `scanf`. I see most senior coders here (and out there) rather encourage the use of `fgets` over `scanf`. I presume the warning you saw referred to that `gets` function? http://www.cplusplus.com/reference/cstdio/gets/ http://www.cplusplus.com/reference/cstdio/scanf/ https://en.cppreference.com/w/c/io/fgets
19th Aug 2019, 7:27 AM
Ipang
+ 1
You're welcome owel
19th Aug 2019, 12:03 PM
Ipang
0
/* like the code below it works fine in sololearn compiler but when it comes in my laptop this could give a warning */ #include <stdio.h> int main() { char a[100]; gets(a); printf("You entered: %s", a); return 0; }
19th Aug 2019, 6:16 AM
oel_arimla
oel_arimla - avatar
0
Ipang thanks for the useful resources.
19th Aug 2019, 9:26 AM
oel_arimla
oel_arimla - avatar