Re: [Dev-C++] Dev-cpp support for getline
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Michael C U. <mu...@cb...> - 2004-10-11 23:06:09
|
Dave,
getline() does not exist in the mingw32 port of GCC (it is a GNU specific
extension that is not part of ISO C).
Your best bet is fgets() if you want to make sure that you cannot cause a
buffer overflow when reading in data.
On Mon, 11 Oct 2004, Dave Sergeant wrote:
> 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
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
> Use IT products in your business? Tell us what you think of them. Give us
> Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
> http://productguide.itmanagersjournal.com/guidepromo.tmpl
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|