0
why some code in sololearn run in my machine and others are not?
4 Réponses
+ 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
+ 1
You're welcome owel ✌
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;
}
0
Ipang thanks for the useful resources.