How do I output an individual character when using char *[] = "something"
- by Matt
I've been playing with pointers to better understand them and I came across something I think I should be able to do, but can't sort out how. The code below works fine - I can output "a", "dog", "socks", and "pants" - but what if I wanted to just output the 'o' from "socks"? How would I do that?
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 of C++ pointer related question, and I spent about 90 minutes looking through them, as well as reading various (very informative) articles, before deciding to ask.