Reputation: 37
In main.cpp I must print my char array like this:
const char *str(CValue::TestStringValue0());
cout << ' ' << *str << endl; //must not change
I can't modify this! So I need to print my array of char, but nor first value of array.
TestStringValue look like this..
static const char* TestStringValue0() {...}
Upvotes: 0
Views: 199
Reputation: 310980
const char *str(CValue::TestStringValue0());
const char *p = str;
for ( ; *str; ++str )
{
cout << ' ' << *str << endl; //must not change
}
:)
Upvotes: 1
Reputation: 7764
I'm not sure I understand you correctly, but if you're not supposed to modify this line:
cout << ' ' << *str << endl; //must not change
Then you can do like this:
const char *tempStr(CValue::TestStringValue0());
const char **str = &tempStr;
cout << ' ' << *str << endl; //must not change
In this case cout will print the whole string returned from TestStringValue0, while in the original code it printed only the first char.
P.S. What a strange condition you have :)
Upvotes: 1