Alternative for getline() function in AIX 5.3

Alternative for getline() function in AIX 5.3

Nadav Har'El nyh at math.technion.ac.il
Tue Jul 27 14:02:39 IDT 2010


On Tue, Jul 27, 2010, Israel Shikler wrote about "Alternative for getline() function in AIX 5.3":
> I am looking for an alternative to getline(), that would be portable to both
> Linux and AIX.

The first obvious alternative is to use fgets(). fgets(), unlike gets(),
is secure because you give it the buffer's length. Nobody should EVER use
gets(), but fgets() is perfectly fine (unless I'm missing something).

The second alternative is to make use of the wonderful fact that Linux is
free software, and just take the source code of getline() and incorporate
it in your program! I can't imagine that getline() is more than a couple
of dozen lines - it's not that complicated... In fact, you can probably
easily write one yourself...

Nadav.


-- 
Nadav Har'El                        |         Tuesday, Jul 27 2010, 16 Av 5770
nyh at math.technion.ac.il             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |If I am not for myself, who will be for
http://nadav.harel.org.il           |me? If I am only for myself, who am I?



More information about the Linux-il mailing list