Programming Algorithms Question:

Write a function that finds the last instance of a character in a string

Programming Algorithms Interview Question
Programming Algorithms Interview Question

Answer:

char *lastchar(char *String, char ch)
{
char *pStr = NULL;

// traverse the entire string

while( * String ++ != NULL )
{
if( *String == ch )
pStr = String;
}

return pStr;
}


Previous QuestionNext Question
What is comp.ai.genetic all about?Return Nth the node from the end of the linked list in one pass.