Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am really lost on this question: Write a code for a function which is given (a

ID: 3625017 • Letter: I

Question

I am really lost on this question:

Write a code for a function which is given (as arguments) char *p (pointing to the start of the string), char c, and returns a char *q to the *second * occurrence of the character c in the string, or a NULL pointer if c is not found at least twice in the string.

Any help will be greatly appreciated.

Another question: http://www.cramster.com/answers-apr-11/computer-science/programming-question-shown-type-definition-node-linked-li_1250132.aspx

Explanation / Answer

char* get_second(char *p, char c) { unsigned char num_found = 0; while (*p != '') { if (*p == c) { num_found++; } if (num_found >= 2) { return p; } ++p; } return 0; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote