• <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.

            統計

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

            2021少妇久久久久久久久久| 2020久久精品国产免费| 色偷偷91久久综合噜噜噜噜| 日韩十八禁一区二区久久| 中文字幕乱码久久午夜| 久久综合九色综合97_久久久| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久久久国产精品麻豆AR影院 | 一本色道久久HEZYO无码| 2022年国产精品久久久久| 久久性生大片免费观看性| 久久无码人妻一区二区三区午夜| 一级做a爰片久久毛片16| 久久久精品国产免大香伊| 成人精品一区二区久久久| 青青草原精品99久久精品66| 久久久久亚洲爆乳少妇无| 国产精品久久波多野结衣| 国内精品综合久久久40p| 激情久久久久久久久久| 亚洲人成精品久久久久| 亚洲欧美精品一区久久中文字幕| 日本久久久久亚洲中字幕| 人人狠狠综合88综合久久| 一本一道久久精品综合| 久久精品国产亚洲AV麻豆网站 | 国产精品综合久久第一页 | 中文字幕久久波多野结衣av| 国产午夜精品久久久久九九电影| 99精品国产在热久久| 精品久久无码中文字幕| 人妻无码久久一区二区三区免费 | 久久精品无码专区免费| 狠狠色丁香婷婷久久综合不卡| 国产成人精品综合久久久| 精品久久久一二三区| 久久这里都是精品| 久久久噜噜噜久久中文字幕色伊伊| 精品久久久久久久久久久久久久久 | 久久精品国产一区| 久久精品国产99国产精偷|