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

            亚洲精品无码成人片久久| 国产一级持黄大片99久久| 久久无码高潮喷水| 色婷婷久久综合中文久久蜜桃av | 欧美亚洲国产精品久久久久| 一级做a爰片久久毛片免费陪| 久久人人爽人人爽人人av东京热| 久久水蜜桃亚洲av无码精品麻豆| 久久久久国色AV免费看图片| 久久ZYZ资源站无码中文动漫| 久久国产午夜精品一区二区三区| 亚洲AV无码久久精品成人| 国产 亚洲 欧美 另类 久久| 亚洲AV无码久久寂寞少妇| 日韩十八禁一区二区久久| 久久AAAA片一区二区| 99久久精品免费看国产一区二区三区| 久久一本综合| 国产精品久久久久久久久鸭 | 青青青青久久精品国产h| 亚洲精品tv久久久久久久久久| 久久国产一区二区| 午夜精品久久久久久久久| 久久久久久一区国产精品| 久久国产乱子伦精品免费强| 久久综合狠狠综合久久| 久久婷婷色香五月综合激情| 三级韩国一区久久二区综合| 国内精品久久久久久久亚洲| 国产叼嘿久久精品久久| 久久国产精品一区二区| 国产精品一久久香蕉国产线看观看| 精品熟女少妇AV免费久久| 漂亮人妻被中出中文字幕久久 | 久久婷婷是五月综合色狠狠| 久久久久亚洲精品天堂久久久久久 | 日韩欧美亚洲国产精品字幕久久久 | 日韩亚洲欧美久久久www综合网| 97久久超碰成人精品网站| 久久久久久午夜成人影院| 久久亚洲日韩精品一区二区三区|