gNash wrote:
i have a problem to receive string from keyboard which is very
long...
Get a shorter keyboard.
(C doesn't know about "keyboards". It does know about `stdin`, though.)
i have a pointer variable. using this how can i get variable
length of character streams. the streams in terms of 10000 may even
more with all the characters like tab, space, newline .. i do not want
to use fixed or static array.
What exactly are you trying to read? Because it sounds to me as
though you want to read everything, not even stopping at newlines.
In which case, `fread` is your chap: he can read as much as you
ask for (up to whatever's available).
int main()
{
char *ptr;
scanf("%s",ptr);
}
Well, I can't see how you ever thought that would work, since `ptr`,
which is supposed to point to somewhere big enough to hold whatever
`scanf` reads, doesn't point anywhere at all.
You'll need to allocate store using `malloc` and, if it turns out
that there's more you want to read, make it bigger using `realloc`.
Both of these should be described in your C book and whatever
online documentation you have to hand. It's not hard if you pay
attention to the details.
--
"We live for the One, you die for the One." Unsaid /Babylon 5/
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN