Proper way to input a dynamically-allocated string
- From: "Michel Rouzic" <Michel0528@xxxxxxxx>
- Date: 9 Dec 2005 04:25:17 -0800
I know it must sound like a newbie question, but I never really had to
bother with that before, and I didn't even find an answer in the c.l.c
FAQ
I'd like to know what's the really proper way for input a string in an
array of char that's dynamically allocated. I mean, I wish not to see
any such things as char mystring[100]; I don't want to see any number
(if possible) I just want to declare something like char *mystring; and
then I don't know how allocate it with just as many chars (with the
space for the \0 of course) as you get from stdin.
I'd really like to know once for all what's the smartest way of
inputing strings from stdin and storing them in a way so they take just
the needed space and I don't want to see any number such as 100 or
10,000 or even 4,294,967,296 in my code. Any way it can be done?
.
- Follow-Ups:
- Re: Proper way to input a dynamically-allocated string
- From: websnarf
- Re: Proper way to input a dynamically-allocated string
- From: slebetman@xxxxxxxxx
- Re: Proper way to input a dynamically-allocated string
- From: Eric Sosman
- Re: Proper way to input a dynamically-allocated string
- From: Dag-Erling Smørgrav
- Re: Proper way to input a dynamically-allocated string
- Prev by Date: newbie question - clearing the scr :S
- Next by Date: Re: typedef void foo_t()
- Previous by thread: newbie question - clearing the scr :S
- Next by thread: Re: Proper way to input a dynamically-allocated string
- Index(es):
Relevant Pages
|