Difference between revisions of "Interview Preparation Strings"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Created page with "== Reverse a string == <syntaxhighlight lang="c"> void reverse_str(char *s) { const int len = strlen(s); const int mid = len / 2; for (int i = 0, j=len-1; i < mid;...")
(No difference)

Revision as of 16:51, 9 July 2013

Reverse a string

void reverse_str(char *s)
{
    const int len = strlen(s);
    const int mid = len / 2;
    for (int i = 0, j=len-1; i < mid; i++, j--) {
        char c = s[i];
        s[i]   = s[j];
        s[j]   = c;
    }
}


Reverse words in a string

TODO


Find the last word in a string

TODO


TODO : More string questions