Interview Preparation Strings
From Embedded Systems Learning Academy
					Revision as of 16:51, 9 July 2013 by Preet (talk | contribs) (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;...")
Contents
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
 
							