Bill Cunningham said:
Lew Pitcher wrote:
[snip]
Oops. Let's not propogate Bill's typo.
The original statement was...
*cp++ = '\0';
Not really. This gets down into a part of C that has escaped me. I
understand creating a pointer and using one.
char *cp;
cp=malloc(); for example.
You know that malloc requires an argument specifying the number of bytes
to allocate, don't you?
But no, you really don't understand "creating a pointer and
using one". The above creates a pointer and assigns a value to it.
It doesn't use it.
But when does one want to use *cp instead of cp as a pointer? I hope I'm
clear.
This is very fundamental stuff. If you're still having such
difficulty with it after all these years, then I suggest that
dealing with tftp headers is beyond you for the foreseeable future.
You have a long history of starting on some ambitious project,
asking questions about very low-level aspects of the language
(imagine an amateur carpenter trying to build a house asking how
nails work), and then moving on to some other ambitious project
without any sign of having finished the previous one.
You're trying to do something with tftp headers. *What* are you
trying to do with them? If your goal is to write a program,
what exactly will that program do?
But ok, to answer your specific question:
Your question "But when does one want to use *cp instead of cp as
a pointer?" really doesn't make much sense.
cp is a pointer. Specifically, it's a pointer to char.
*cp is the char object that cp points to. *cp is not a pointer,
and cannot be used as one.
Again: cp is a pointer, *cp is not a pointer.