其他分享
首页 > 其他分享> > c字符数组之两头堵模型

c字符数组之两头堵模型

作者:互联网

char[length]="特别车队"其实等价于char *mywords="特别车队"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    char * words="    特别车队狮哥候警官老狒";
    int i,j=0;
    j=strlen(words)-1;
    while(isspace(words[i]) && words[i]!='\0')
    {
        i++;
    }
    while(isspace(words[j]) && words[j]!='\0')
    {
        j--;
    }
    int n=j-i;

    printf("%d\n",n);
    while(i<=j){
        printf("%c",words[i]);
        i++;
    }
    printf("\n%s\n",words);
    return 0;
}

标签:字符,数组,int,车队,char,while,words,两头,include
来源: https://www.cnblogs.com/saintdingspage/p/12048563.html