I am wondering how you read this line of code:
for(const char*c = inputLetters.c_str();*c; ++c)
I understand the inputLetters.c_str() and the ++C, but what does const char*c mean and the *c?
thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
char inLetters;
string inputLetters;
inLetters = 0;
int loopCount=1;
int letterCount=0;
// Read Input Data
cout << "Enter a word for the corresponding print out of" << endl << " Civil Aviation Organization Alphabet." << endl;
cin>>inputLetters;
cout<< "The International Civil Aviation Code words for the letters you input are: " << endl;
for(constchar*c = inputLetters.c_str();*c; ++c)
{
if(loopCount<=26)
letterCount++;
loopCount++;
It is a poorly formed loop, as it will not always iterate over all characters in the string. If the string contains a null character (yes, std::string supports holding strings with null characters), then the loop will stop early.