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

            欧美激情精品久久久久| 日本久久久久久久久久| 人妻精品久久无码专区精东影业| 亚洲va国产va天堂va久久| 久久精品国产69国产精品亚洲| 国内精品久久久久久麻豆| 人妻无码αv中文字幕久久| 久久91精品综合国产首页| 无码人妻少妇久久中文字幕蜜桃| a级毛片无码兔费真人久久| 麻豆精品久久久久久久99蜜桃| 久久综合综合久久97色| 久久久久久久91精品免费观看| 日韩一区二区久久久久久| 亚洲国产精品高清久久久| 99久久成人18免费网站| 色偷偷偷久久伊人大杳蕉| 久久久精品国产| 欧美久久一区二区三区| 国产精品VIDEOSSEX久久发布| 久久精品麻豆日日躁夜夜躁| 久久久这里有精品| 一级做a爰片久久毛片免费陪| 韩国三级中文字幕hd久久精品 | 婷婷久久综合| 久久国产成人午夜AV影院| 久久99精品国产99久久| www性久久久com| 久久99国产精品久久久 | 99久久免费国产精品特黄| 日韩中文久久| 韩国三级中文字幕hd久久精品| 亚洲精品无码久久一线| 久久综合亚洲色HEZYO社区| 武侠古典久久婷婷狼人伊人| 久久露脸国产精品| 亚洲?V乱码久久精品蜜桃| 精品国产综合区久久久久久| 热RE99久久精品国产66热| 伊人色综合久久天天网| 日韩欧美亚洲综合久久|