• <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)計(jì)

            留言簿(1)

            他山之石

            閱讀排行榜

            評(píng)論排行榜

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

            久久有码中文字幕| 久久久久亚洲av无码专区导航| 精品久久久久久中文字幕| 久久91精品久久91综合| 国产精品欧美久久久久天天影视| 国产 亚洲 欧美 另类 久久| 亚洲国产综合久久天堂 | 精品久久久久久久久免费影院| 久久久久亚洲国产| 久久精品国产69国产精品亚洲| 久久精品亚洲男人的天堂| 九九精品久久久久久噜噜| 久久久久无码精品国产不卡| 国产高潮久久免费观看| 色妞色综合久久夜夜| 国产精品99久久久久久猫咪| 久久精品国产久精国产一老狼| 亚洲国产天堂久久综合网站| 久久亚洲精品无码AV红樱桃| 久久免费视频一区| 欧美精品一区二区精品久久| 99久久99久久精品国产片果冻 | 亚洲色婷婷综合久久| 99久久国产综合精品五月天喷水| 男女久久久国产一区二区三区| 久久国产视屏| 久久这里只精品国产99热| 亚洲国产精品无码久久久秋霞2| 久久精品这里只有精99品| 色综合久久久久| 国产精品久久久久无码av| 亚洲狠狠婷婷综合久久蜜芽| 久久夜色精品国产亚洲| 午夜精品久久久久9999高清| 欧美性大战久久久久久| 精品久久久久久无码人妻蜜桃| 久久亚洲AV成人出白浆无码国产 | 97精品久久天干天天天按摩| 欧美一区二区三区久久综合| 色综合久久无码中文字幕| 欧美丰满熟妇BBB久久久|