gets

Recovering from a broken TCP socket in Ruby when in gets()

I'm reading lines of input on a TCP socket, similar to this: class Bla def getcmd @sock.gets unless @sock.closed? end def start srv = TCPServer.new(5000) @sock = srv.accept while ! @sock.closed? ans = getcmd end end end If the endpoint terminates the connection while getline() is running then ...

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 warning message not to pop up.Is there any way? I am wondering that there might be such possibilities by creating a header file for disabli...

gets() does not work

I have a program written in C and it calls gets() from a switch when a user chooses the option of 3. Here is my code. It does not seem to wait to wait for the user to input something. Rather the program continues in the switch. void getField(); #include <stdio.h> #include <string.h> /*#include "stubs.c" #include "record.h" */ int debu...

Why is the `gets' function is dangerous? Why should not be used?

When I try to compile C code that uses the gets function, I get a warning: warning: the gets function is dangerous and should not be used. I remember this has to do something with stack protection and security, but I'm not sure. Can someone help me with removing this warning and explain why is there such warning? If gets is "dangerous" ...

CR character in gets() function

The user types a string, possibly separated by tabs, spaces and "enters" (CRs). I need to receive all of it; the problem is that gets() function stops the scan when the user presses the "Enter" key. Is there another way to do it? I cannot use any other function except for scanf and gets. ...

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 dies with the following error: ruby main.rb -i main.rb:74:in `gets': No such file or directory - -i (Errno::ENOENT) from main.rb:74:in ...

How do you use sets and gets in C++?

I've used them in java and didn't seem to have too many issues, but I'm not grasping them very well in C++. The assignment is: Write a class named Car that has the following member variables: year. An int that holds the car's model year. make. A string that holds the make of the car. speed. An int that holds the car's curr...

Input in C. Scanf before gets. Problem.

Hi! 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; char b[20]; printf("Input your ID: "); scanf("%d", &a); printf("Input your name: "); gets(b); printf("---------"); printf("Name: ...

gets (variable)

can anyone tell me why gets(abc) works with char[] but not with int? int abc; char name[] = "lolrofl"; printf("Hello %s.\n",name); printf("\n >> "); fflush(stdin); gets (abc); printf("\n die zahl ist %i.\n",abc); system("Pause"); return(0); ...

if one complains about gets(), why not do the same with scanf("%s",...)?

From man gets: Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security. Use fg...

gets() taking input without actually giving it any input?

Hi all, I'm fairly new to C so sorry if this is a stupid question but when I run the following code: #include <stdio.h> int main () { int i; int test[10]; char string[81]; for(i = 0; i < 10; i++){ scanf("%d", &test[i]); } for(i=0; i < 7; i++){ gets(string); printf("String was entered\...