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

            国产午夜电影久久| 久久综合狠狠综合久久| 久久免费线看线看| 国产L精品国产亚洲区久久| 激情综合色综合久久综合| 久久精品中文字幕第23页| 中文字幕久久精品无码| 久久免费视频网站| 久久人与动人物a级毛片| 国产午夜精品久久久久免费视 | 久久综合综合久久97色| 国产精品综合久久第一页| 久久精品中文字幕一区| 国产精自产拍久久久久久蜜| 欧美激情一区二区久久久| 久久亚洲国产精品一区二区| 亚洲综合久久夜AV | 久久se精品一区精品二区| 日本欧美国产精品第一页久久| av无码久久久久久不卡网站| 久久久www免费人成精品| 久久久久亚洲精品天堂久久久久久| 嫩草伊人久久精品少妇AV| 日韩欧美亚洲综合久久影院Ds| 伊人久久精品线影院| 久久亚洲私人国产精品vA| 久久精品国产亚洲AV久| 亚洲国产成人久久综合一区77| 久久精品免费网站网| 久久精品国产WWW456C0M| 久久青草国产精品一区| 国内精品伊人久久久久| 久久国产亚洲高清观看| 婷婷久久久亚洲欧洲日产国码AV| 久久综合久久伊人| 久久九色综合九色99伊人| 久久丝袜精品中文字幕| 国产99久久久国产精免费| 欧美久久综合性欧美| 久久久精品一区二区三区| 亚洲国产精品婷婷久久|