[Dev-C++] Again with: gets,fgets,getline
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <vil...@ya...> - 2001-04-19 09:16:01
|
<I have experienced problems with the function "gets".
<It seems that in my program is using memory addresses that shouldn't use
because <it writes on some of my dynamic memory space.
<
<I have read the "The GNU C Library" and while trying to use "getline" instead
of <"gets", it seems that getline is not in "stdio.h". In fact, searching for
it in <"stdio.h" like >Ctrl+F-> "getline", it doesn't found it.
<I dunno what's happening.
<Does anybody know anything I can try?
Here I have an example:
/*------------------------------------------------------*/
#include <stdio.h>
int main()
{
char pep[255],pitu[255],nitu[255],*pt,*ptg;
int i;
FILE *fp;
printf("Write something\n");
gets(pep);
printf("Write something more\n");
fgets(pitu,255,fp);
printf("Write something more again\n");
pt = (char)malloc(256*sizeof(char));
getline(pt,255,fp);
system("PAUSE");
return 0;
}
/*------------------------------------------------------*/
_______________________________________________________________
Do You Yahoo!?
Envía mensajes instantáneos y recibe alertas de correo con
Yahoo! Messenger - http://messenger.yahoo.es
|