bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gets and terminating \n


From: Billoud Bernard
Subject: gets and terminating \n
Date: Thu, 15 Feb 2001 19:38:57 +0100

Hello,

I have glibc 2.1.3 under linux, and the standard irix libc under sgi.

This is a short code using gets.
It does not behave the same under linux and sgi...

The '\n' character is not removed under linux, while it is under sgi.


#include <stdio.h>

void main (void){
  char foo[30]; 
  printf (">");
  gets (foo);
  printf ("\n>>%s>>\n", foo);
}

sgi output :
------------------------
abikini 102% gcc -o toto toto.c
toto.c: In function `main':
toto.c:3: warning: return type of `main' is not `int'
abikini 103% toto
>eric

>>eric>>
------------------------

linux output :
------------------------
address@hidden clustalw1.81]$ gcc -o toto toto.c
toto.c: In function `main':
toto.c:3: warning: return type of `main' is not `int'
/tmp/ccEMPuD8.o: In function `main':
/tmp/ccEMPuD8.o(.text+0x1e): the `gets' function is dangerous and should not be 
used.
address@hidden clustalw1.81]$ toto
>eric
 
>>eric
>>
------------------------

After having made a "man gets", I think that sgi has the right
solution.

Sincerely

Bernard Billoud
                                                                                
                     
-- 
Bernard Billoud - Atelier de BioInformatique | You've got the answer   |
 Université Pierre et Marie Curie (Paris 6)  |  in your hand ?         |
Esc.A, 3e Et. - 12, rue Cuvier - 75005 Paris | Throw it away.          |
Tel. (1) 44 27 65 82 ~~ Fax. (1) 44 27 63 12 |           (Joe Jackson) |



reply via email to

[Prev in Thread] Current Thread [Next in Thread]