[Dev-C++] Dev-cpp support for getline
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Dave S. <da...@da...> - 2004-10-11 17:41:20
|
Hi
I am in the process of coming to grips with C and eventually C++ and
working through various tutorials, currently the GNU C Programming
Tutorial by Mark Burgess. I am running Dev-cpp 4.9.9.0 on Windows
98SE.
The tutorial stresses the use of getline, getdelim, and other
functions introduced with GNU C instead of the deprecated scanf etc.
But I can't seem to get getline to work with dev-cpp. If I try and
compile the program below, which is from the tutorial, I get a linker
error 'undefined reference to 'getline' '.
I have tried searching this mailing list and the forums and cannot
find a solution, apart from getting the impression that others seem
to be able to use it with no problem.
Do I need to download an updated <stdio.h> or other library?
Thanks
Dave Sergeant
Example program:
#include <stdio.h>
int main()
{
int bytes_read;
int nbytes = 100;
char *my_string;
puts ("Please enter a line of text.");
/* These 2 lines are the heart of the program. */
my_string = (char *) malloc (nbytes + 1);
bytes_read = getline (&my_string, &nbytes, stdin);
if (bytes_read == -1)
{
puts ("ERROR!");
}
else
{
puts ("You typed:");
puts (my_string);
}
return 0;
}
http://www.davesergeant.com
|