Programming Pearls: Chatper3 Problem3 [Print Banner]
ProgrammingPearlsChapter3Problem3
The output is like this:
xxxxxxxxx
xxxxxxxxx
xx
xx
xx
xx
xx
xx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxx
xxx
xxx
xxx
xxx
xxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
Lesson Learned:
1. When you define a local variable inside the loop {...}, it means that this variable will be initialized every time the loop executes.
2. isdigit() and isalpha() can be used to check if the item falls in the range we expected.
3. When you wrote the loop using while, remember to advance the variable so that the loop can end:
while(*p!='\0')
{
p++; //Remember to add this statement
}