Hi again Wade::
Wade Carpenter,
In a message on 24 July, you wrote to me :
WC>
WC> Yep.. It worked like a charm!!! Thanks so much for the help,
WC> because I never
WC> would have thought of that!! So, would it generally be better then, to
WC> use 'char any[50]' instead of using 'char *any'?
The -- char *any -- has the advantage in that you could change the amount of
memory allocated to it by calling -- realloc() -- or you could return the
memory occupied by it back to the system with -- free() --
But if you have an object that's gonna occupy more or less same a fixed
amount of memory then using the -- char any[50] -- is better. Then you
don't have to call any -- malloc() -- or -- realloc() s--
TIP::
Also, when you want to pass 'any' as an argument to a function say
foo(char *gimmeAny) then you could use foo(any) where any is either a
char * or char any[].
So you see, there's no *general* way of doing things in C.
WC> Before now, I never knew
WC> any reason to specify the length, other than writing to files...
Well, good things come to those who wait.
For C/C++ beginners learning how pointers work is the biggest challenge.
Keep it up
Bye
Rajesh
...
* ATP/Linux 1.50 * Nelson Eddy & Jenny MacDonald: "Ah, Sweet Mystery of
fe"
--- Maximus/2 3.01
---------------
* Origin: Kalptaru Net India. http://www.kalptaru.com . (6:606/31)
|