Tuesday, March 30, 2010

Problems on String Manipulation

Objective:- Print alternate characters of a string.

Process:-

void DisplayAlternateCharacters(char strSource[])
{
//Loop counter
int iLoopCounter = 1;

//***************************************************************************************
//We will hop the counter 2 steps at a time. The termination condition will check against
//the characters pointed to by both the current counter and the its preceeding counter.
//***************************************************************************************

for (; (strSource[iLoopCounter] != '\0') && (strSource[iLoopCounter - 1] != '\0');
iLoopCounter += 2)
printf("%c\n", strSource[iLoopCounter]);
}

No comments:

Post a Comment