The code pName = &name should be either pName = name or pName = &name.
Actually pName = &name; isn't valid, because you try to convert char* to string*. Also char* pColor = &color; will do you no good, since &color references some memory area that color itself doesn't have it. Since char color= "white"; is an array of characters of length 6 (including '\0'), &color will point to a totally different memory area, and if printing, it might yeld odious results. If, say, you were to take something like this:
char* pColor = &color;
pColor will than point to the memory area of an array of chars starting from i, e.g. ite
after my changes I get the following output Interger has a memory address 0x7fff5fbffac4 String has a memory address 0x7fff5fbffaa0 Array has a memory address 0x7fff5fbffa6c Array has a memory address 0x7fff5fbffa70 Array has a memory address 0x7fff5fbffa74 Array has a memory address 0x7fff5fbffa74 Char has a memory address 0x7fff5fbffa80 Char has a memory address 0x7fff5fbffa88 Char has a memory address 0x7fff5fbffa90 Char has a memory address 0x7fff5fbffa98 Char has a memory address 0x7fff5fbffaa0 Double has a memory address 0x7fff5fbffa98
noting that as what Lucaci Andrew said "&color will point to a totally different memory area" I changed it to &pColor+i to point to the first letter address
Re Andrew's response - doh! Thanks! Brain fart there! Absolutely correct! I think I had just responded to a C query so brain was still in K&R mode, not E&S mode... :-) If I could vote down my previous post I would. :rolleyes:
From the department of excuses department: It was late when I read the post! I was tired! My glasses were dirty! Aren't all strings char* types? :lol: