• <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 閱讀(218) 評論(0)  編輯 收藏 引用 所屬分類: Snippet

            久久午夜福利无码1000合集| 伊人久久大香线蕉综合Av| 久久久这里有精品| 亚洲av日韩精品久久久久久a| 日产精品久久久久久久| 亚洲国产二区三区久久| 一本一道久久a久久精品综合 | 国产激情久久久久影院| 亚洲精品久久久www| 久久久久AV综合网成人| 伊人色综合九久久天天蜜桃 | 国产精品成人无码久久久久久 | 亚洲午夜久久久影院伊人| 青青青国产精品国产精品久久久久| 国内精品久久久久久久久电影网 | 97精品国产97久久久久久免费 | 亚洲va中文字幕无码久久| 久久精品草草草| 精品久久久久久中文字幕人妻最新| 久久精品国产亚洲AV忘忧草18| 久久久久国产一级毛片高清板| 国产精品久久波多野结衣| 久久久国产乱子伦精品作者 | 国产午夜精品久久久久免费视 | 中文字幕热久久久久久久| 久久99久久无码毛片一区二区| 国产精品九九久久免费视频 | 好久久免费视频高清| 2020国产成人久久精品| 久久久艹| 爱做久久久久久| 99久久国产综合精品五月天喷水| 久久99国产综合精品| 久久亚洲国产成人精品性色| 久久精品中文无码资源站| 日韩欧美亚洲综合久久| 欧美国产精品久久高清| 亚洲精品无码久久久久去q| 久久人人爽人人爽人人片av麻烦| 要久久爱在线免费观看| 99久久香蕉国产线看观香|