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

            性做久久久久久久久久久| 麻豆久久久9性大片| 91精品国产乱码久久久久久| 婷婷久久香蕉五月综合加勒比| 久久无码人妻一区二区三区| 97热久久免费频精品99| 久久久久97国产精华液好用吗| 久久久久久久精品妇女99| www.久久热| 亚洲国产另类久久久精品小说| 久久91精品国产91久久户| 国产精品亚洲综合久久| 色综合久久天天综合| 伊人久久无码中文字幕| 九九久久精品无码专区| 精品熟女少妇a∨免费久久| 亚洲七七久久精品中文国产| 亚洲精品国产成人99久久| 伊人久久精品无码av一区| 三级片免费观看久久| 国产高清美女一级a毛片久久w| 久久人人爽爽爽人久久久| 日韩一区二区三区视频久久| 久久精品国内一区二区三区| 亚洲va中文字幕无码久久不卡| 久久九九青青国产精品| 麻豆亚洲AV永久无码精品久久| 久久久午夜精品| 久久亚洲熟女cc98cm| 国产精品久久久香蕉| 深夜久久AAAAA级毛片免费看| 91亚洲国产成人久久精品| 久久er国产精品免费观看2| 久久精品国产99国产精品亚洲| 伊人色综合久久天天网| 久久久精品国产Sm最大网站| 精品久久久久久无码中文野结衣 | 久久91这里精品国产2020| 久久国产精品99国产精| 久久久国产精品亚洲一区| 亚洲精品无码久久一线|