Thread: [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
|
|
From: Per W. <pw...@ia...> - 2004-10-11 22:11:52
|
Sorry, no getline() with the C libraries for MinGW.
However, before starting to use gnu-specific extensions, I woule really
recommend you to think twice. If you are working on gnu tools, it might be
a good decision, but for most other C programming, I think it is better to
rely on standardized functions.
/Per W
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
>
|
|
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
>
|
|
From: Dave S. <da...@da...> - 2004-10-12 08:28:49
|
Many thanks to Per and others for their quick relies. Back to the tutorials... Dave Sergeant On 12 Oct 2004 at 0:11, Per Westermark wrote: > Sorry, no getline() with the C libraries for MinGW. > > However, before starting to use gnu-specific extensions, I woule > really recommend you to think twice. If you are working on gnu tools, > it might be a good decision, but for most other C programming, I think > it is better to rely on standardized functions. > > /Per W > > 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 http://www.davesergeant.com |