I played with pointers to better understand them, and I came across what I think I should have done, but can't figure out how to do this. The code below works fine - I can output "a", "dog", "socks" and "pants", but what if I just want to get the "o" out of the "socks"? How should I do it?
char *mars[4] = { "a", "dog", "sock", "pants" };
for ( int counter = 0; counter < 4; counter++ )
{
cout << mars[ counter ];
}
Please forgive me if the question is answered somewhere - there are 30+ pages related to the C ++ pointer, and I spent about 90 minutes looking at them, and also read various (very informative) articles before making a decision .
source
share