The "C language" flips the string order, such as: I am a student turns: Student a AM I

Source: Internet
Author: User
Flip the string sequence//such as: I am a student  to: Student a am i#include <stdio.h> #include <string.h>void fanw (char *left, Char *right)//turn each word word upside down {char* Pleft = left;char* pright = Right;char temp;while (Pleft < pright) {temp = *pleft;*plef t = *pright;*pright = temp;pleft++;p right--;}} void fans (char *p)  //Find the word {while (*p! = '} ') in the string {char *pst = p;while (*p! = ' && *p! = ') {p++;} FANW (pst,p-1);p + +;}} int main () {char p[30] = "Student a Am I"; int len = strlen (P);p rintf ("The original string is:%s\n", p);p rintf ("The string after flipping is:"); Fanw (p,p+len-1) ; fans (P);p rintf ("%s\n", p); return 0;}

The "C language" flips the string order, such as: I am a student turns: Student a AM I

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.