• <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)計

            留言簿(1)

            他山之石

            閱讀排行榜

            評論排行榜

            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 閱讀(218) 評論(0)  編輯 收藏 引用 所屬分類: Snippet

            久久久久久久久久久免费精品| 久久精品国产AV一区二区三区| 狠狠色丁香久久综合五月| 久久久久综合网久久| 久久国产一片免费观看| 无码任你躁久久久久久久| 人妻精品久久无码专区精东影业| 浪潮AV色综合久久天堂| 精品久久综合1区2区3区激情 | 久久国产精品一国产精品金尊| 久久精品人人槡人妻人人玩AV| 国产成人综合久久久久久| 精品国产乱码久久久久久人妻| 99久久精品国产免看国产一区| 四虎久久影院| 99久久99久久精品免费看蜜桃| 热RE99久久精品国产66热| 精品久久一区二区| 色欲av伊人久久大香线蕉影院| 国产综合成人久久大片91| 777米奇久久最新地址| 亚洲欧洲日产国码无码久久99| 国产精品青草久久久久福利99| 中文字幕热久久久久久久| 狠狠精品干练久久久无码中文字幕| 久久久久亚洲精品天堂| 性做久久久久久久久老女人| 国产精品亚洲美女久久久| 久久国产成人精品麻豆| 久久久女人与动物群交毛片 | 韩国无遮挡三级久久| 久久婷婷是五月综合色狠狠| 91性高湖久久久久| 青青草原综合久久大伊人精品| 国内精品久久久久影院日本| 无码人妻精品一区二区三区久久久| 女人高潮久久久叫人喷水| 久久99精品久久久大学生| 少妇人妻88久久中文字幕| 久久婷婷五月综合97色一本一本| 77777亚洲午夜久久多喷|