Answer to Question #17738 in C++ for Akhil Menon

Question #17738
WAP having func named search which scans a string from beginning to end in search of a character.If the character is found it should return a pointer to the first occurance of the given character in the string else, the function should return a null,if not found.
1
Expert's answer
2012-11-01T12:21:29-0400

char* search(char* str, char w)
{
for(int i=0;i<strlen(str);++i)
if(str[i]==w)
return (str+i);
return NULL;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS