On Sun, Dec 4, 2011 at 14:32, Mihir Mehta <[email protected]> wrote:
> Hi all,
>
> char user_name[STRING_SIZE];
> printf("Enter the name for this new user.\n");
> scanf("%s", user_name);
>
> This works for now, but I feel that having the string size limited
> this way (by the constant STRING_SIZE) could be a problem, and the
> scanf man page suggests that it is capable of dynamically allocating
> enough space to the character array user_name if it is called
> appropriately.
>
use the scanf as
<code>
scanf("%as",user_name");
</code>
and compile it as
gcc filename.c -o file.out -D __GNU__SOURCE or you can #define __GNU_SOURCE
macro inline in the source file itself rather than defining it in
compilation time.
--
Arjun S R
http://about.me/arjunsr
--
Mailing list guidelines and other related articles: http://lug-iitd.org/Footer