Posted: Mon Oct 01, 2007 5:32 am
If you're programming this in your own OS (A lot of the replies earlier assumed this was in a hosted environment), then you should DEFINATELY use static allocation with a max size, thus:
JamesM
Code: Select all
unsigned int gets(char *buffer, unsigned int max_length)
{
unsigned int sz = 0;
while( (*buffer++=getc()) != '\n' &&
sz < max_length-1)
sz++;
*--buffer = '\0';
return sz;
}
... in main.c ...
char string[512];
gets(string, 512);