Hi all,

I'm programming a terminal-based application with c, and at various
point, I need to prompt the user for input data. For this, I use code
like this:

        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. However, the language of the man page is somewhat
unclear on this point, so could someone help me out by letting me know
what changes I need to make to my code for the desired behaviour?

Thanks,
Mihir.

-- 
Mailing list guidelines and other related articles: http://lug-iitd.org/Footer

Reply via email to