M
Mike Wahler
that explain pointers ?Matthew Jakeman said:Matthew Jakeman said:If i have a pointer, char *.
Note that an object of type 'char*' (pointer to char),
is neither a character nor a string. It can represent
the address of an indivudual character (type 'char')
object. It cannot represent a character or a string.
That i have checked is only 1 character long,
It's very unlikely (but not impossible) that a pointer
on your system is only one character in size. And
again, note that this type can only contain an *address*
of a memory location, not a character value.
is just casting it to a char using (char)
Casting a char* to a char gives undefined (or is it
implementation-defined?) behavior.
the best way or is there another way ?
Best way to do what?
If you have a pointer of type 'char*' which contains the
address of a character object, or the address of the first
of an array of characters, you access the 'pointed to'
character with the dereference operator:
char some_stuff[] = "Hello";
char *p;
char c;
p = &some_stuff[1];
c = *p; /* The object 'c' now contains the character 'e' */
What C book(s) are you reading that don't explain
pointers?
-Mike
At what point in my message did i say i had been reading a C book / books
You didn't. But imo you're only wasting your time
trying to learn C without textbooks. You can't learn
it 'piecemeal' by posting questions to usenet.
I didn't, i asked for help,
Help given here is intended to supplement, not replace,
the more traditional learning materials, such as books.
thanks for the paragraphs that have managed to make a simple question,
Your question wasn't only 'simple', but it was quite vague,
and indicated misconceptions, which I attempted to rectify.
from someone who is obviously dwarfed by your mass of intelligence,
Obnoxious sarcasm won't get you very far here.
turn into something immensely more complex
I don't think any of my explanation of a simple topic
was complex at all. If you find it so, then you really
do need some books.
but the reply before yours was a lot less demeaning
Please point out where in my reply I used any
'demeaning' text. All I did was state facts.
If you're upset with those facts, take it up
with them.
and a hell of a lot more helpful.
It might be, it might not. Joona had to guess at
what you really wanted. He also apparently chose
to overlook the parts of your post that indicate
your misconceptions about C.
-Mike