• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            EverSpring working shop

            To pursue creative ideas based on nature.

            統(tǒng)計(jì)

            留言簿(1)

            他山之石

            閱讀排行榜

            評(píng)論排行榜

            Code Snippet: Trim the unnecessary white space in a sentence.

            This code snippet is trying to trim the unnecessary white space in a sentence to use only one white space between each word.
            The key idea of this code is move the rest of the string to the place just after the white space found each time.
            QUITE simple but useful code snippet.

            Running Enviroment: Visual C++ 2005 Express edition.

             1// string_trim.cpp : Defines the entry point for the console application.
             2//
             3
             4#include "stdafx.h"
             5#include "string.h"
             6
             7/* The Modifications are Made to the Same String */
             8void inside_trim(char* x)
             9{
            10        unsigned int i,pos,nxtchar;
            11 
            12        for(i=0;i<strlen(x);i++)
            13        {
            14                if( x[i] == ' ' )
            15                {
            16                        pos=i+1;
            17                        nxtchar=pos-1;
            18                        while(x[nxtchar++== ' '){}
            19 
            20                        strcpy(&x[pos],&x[nxtchar-1]);  // move forward the rest of the whole string!
            21                        printf("\n%s",x);
            22                }
            23        }
            24}
            25
            26
            27int _tmain(int argc, _TCHAR* argv[])
            28{
            29        char xyz[]="Does      this     work?";
            30        printf("\n%s",xyz);
            31        inside_trim(&xyz[0]);
            32        printf("\n%s",xyz);
            33    
            34    return 0;
            35}
            36
            37

            Running Result:


            posted on 2007-10-12 21:58 everspring79 閱讀(223) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Snippet

            伊人久久五月天| 国产精品美女久久久免费| 国产精品成人久久久| 久久夜色撩人精品国产| 天天爽天天爽天天片a久久网| 精品久久国产一区二区三区香蕉 | 久久精品国产黑森林| 亚洲国产精品久久电影欧美| 亚洲色欲久久久综合网| 久久精品亚洲精品国产色婷| 久久精品国产亚洲网站| 久久国产亚洲精品麻豆| 国产高清国内精品福利99久久| 亚洲色欲久久久久综合网| 亚洲&#228;v永久无码精品天堂久久| 久久综合综合久久综合| 国产精品一久久香蕉国产线看观看 | 国产高清国内精品福利99久久| 久久人妻无码中文字幕| 久久久久国产精品熟女影院| 久久e热在这里只有国产中文精品99| 日产精品99久久久久久| 99久久无码一区人妻a黑| 久久中文字幕一区二区| 亚洲精品无码久久毛片| 久久无码AV中文出轨人妻| 狠色狠色狠狠色综合久久| 久久久久亚洲AV无码去区首| 亚洲中文字幕久久精品无码APP | 久久亚洲国产中v天仙www| 欧美性大战久久久久久| 久久国产成人| 久久99精品久久久久久久不卡| 亚洲精品国产字幕久久不卡| 久久国产精品无码HDAV| 亚洲级αV无码毛片久久精品 | 久久久久久曰本AV免费免费| 99热热久久这里只有精品68| 久久天堂AV综合合色蜜桃网| 久久99精品久久久久久动态图| 久久久久亚洲av无码专区喷水 |