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

            久久久久18| 久久精品国产国产精品四凭| 中文国产成人精品久久亚洲精品AⅤ无码精品| 久久线看观看精品香蕉国产| 久久综合视频网站| 久久亚洲春色中文字幕久久久| 国产成人久久精品激情| 人妻无码久久精品| 久久久久久久综合日本亚洲 | 午夜天堂av天堂久久久| 麻豆精品久久久一区二区| 国产A级毛片久久久精品毛片| 国产—久久香蕉国产线看观看 | 国产精品久久久久无码av| 香蕉aa三级久久毛片| 99久久综合国产精品二区| 天天爽天天狠久久久综合麻豆| 欧美久久一级内射wwwwww.| 久久精品国产精品亚洲精品| 99久久精品免费看国产一区二区三区| 欧美伊香蕉久久综合类网站| 久久久久亚洲av无码专区导航| 中文字幕精品无码久久久久久3D日动漫| 久久精品亚洲一区二区三区浴池 | 狠狠色综合网站久久久久久久高清 | 欧美久久综合九色综合| 久久福利青草精品资源站免费| 亚洲色大成网站WWW久久九九| 伊人色综合久久天天人守人婷| 久久e热在这里只有国产中文精品99| .精品久久久麻豆国产精品| 久久综合九色综合网站| 久久人人妻人人爽人人爽| 色婷婷综合久久久久中文| 亚洲国产精品18久久久久久| 久久亚洲AV成人无码电影| 国产精品美女久久久久网| 亚洲精品国产成人99久久| 99久久婷婷国产一区二区| 久久久久亚洲av毛片大| 亚洲精品国产自在久久|