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

            久久96国产精品久久久| 久久综合精品国产一区二区三区 | 久久99亚洲网美利坚合众国| 久久人人添人人爽添人人片牛牛| 亚洲伊人久久大香线蕉综合图片| 久久99久久99小草精品免视看| 久久久久亚洲AV成人网| 久久久免费精品re6| Xx性欧美肥妇精品久久久久久 | 久久国产免费观看精品3| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久国产欧美日韩精品免费| 亚洲色大成网站WWW久久九九| 久久久网中文字幕| 日本欧美久久久久免费播放网| 久久综合九色综合久99| 99久久精品国产高清一区二区| 亚洲熟妇无码另类久久久| 久久久久无码中| 久久91亚洲人成电影网站| 99精品久久久久久久婷婷 | 久久国产精品久久久| 无码精品久久一区二区三区 | 久久亚洲高清观看| 久久中文骚妇内射| 亚洲精品乱码久久久久久久久久久久 | 国产视频久久| 国产成人久久精品激情| 精品久久久久久国产潘金莲| 亚洲欧美成人久久综合中文网 | 久久国产热精品波多野结衣AV| 久久精品国产亚洲av瑜伽| 国产精品对白刺激久久久| 亚洲AV无码久久寂寞少妇| 久久精品中文无码资源站| 亚洲伊人久久成综合人影院 | 99精品久久久久久久婷婷| 怡红院日本一道日本久久| 色综合色天天久久婷婷基地| 久久棈精品久久久久久噜噜| 国产精品久久午夜夜伦鲁鲁|