All Questions

151
votes
11answers
92763 views

Why is the gets function so dangerous that it should not be used?

When I try to compile C code that uses the gets() function with GCC, I get a warning: (.text+0x34): warning: the `gets' function is dangerous and should not be used. I remember this has someth...
29
votes
7answers
72983 views

C - scanf() vs gets() vs fgets()

I've been doing a fairly easy program of converting a string of Characters (assuming numbers are entered) to an Integer. After I was done, I noticed some very peculiar "bugs" that I can't answer, mos...
25
votes
0answers
15894 views

Safe Alternative to gets

I wanna read a whole line from standard input, including the whitespace between two words. When using gets on gcc I get the following message: send.c:(.text+0x2a): warning: the `gets' function is d...
9
votes
8answers
17836 views

Input in C. Scanf before gets. Problem

I'm pretty new to C, and I have a problem with inputing data to the program. My code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int a; cha...
6
votes
8answers
12028 views

Disable warning messages in GCC through header files?

I am using the function gets() in my C code. My code is working fine but I am getting a warning message (.text+0xe6): warning: the `gets' function is dangerous and should not be used. I want this ...
1
votes
4answers
5645 views

Program doesn't execute gets() after scanf(), even using fflush(stdin)

After wasting too much time searching why my program doesn't execute gets() after using scanf(), I found a solution which is to use fflush(stdin) after scanf() to enable gets() to get a string. The p...
0
votes
1answers
513 views

How do the puts and gets functions work?

main() { char name[20]; printf("enter your name\n"); scanf("%s",name); printf("%s",name); gets(name); puts(name); } input: Sampad Saha Output Sampad Saha Here puts only uses t...
5
votes
5answers
4893 views

Is gets() officially deprecated?

Based on the most recent draft of C++11, C++ refers to ISO/IEC 9899:1999/Cor.3:2007(E) for the definitions of the C library functions (per §1.2[intro.refs]/1). Based on the most recent draft of C99 ...
14
votes
2answers
2465 views

Why is gets throwing an error when arguments are passed to my ruby script?

I'm using gets to pause my script's output until the user hits the enter key. If I don't pass any arguments to my script then it works fine. However, if I pass any arguments to my script then gets d...
3
votes
2answers
1102 views

gets.chomp without moving to a new line

I understand about the \n that's automatically at the end of puts and gets, and how to deal with those, but is there a way to keep the display point (the 'cursor position', if you will) from moving to...

Previous Next