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

            欧美久久久久久精选9999| 久久精品女人天堂AV麻| 日本欧美久久久久免费播放网| 久久成人国产精品免费软件| 亚洲精品tv久久久久久久久| 久久夜色tv网站| 综合久久精品色| 国产精品久久久久久一区二区三区| 国产精品天天影视久久综合网| 欧美性大战久久久久久| 久久综合给合久久狠狠狠97色| 久久伊人精品青青草原高清| 午夜精品久久久久成人| 91精品国产高清久久久久久io| 亚洲欧美另类日本久久国产真实乱对白 | 色综合久久无码五十路人妻| 精品一区二区久久| 7777精品久久久大香线蕉| 国产日韩久久免费影院| 久久久久久久97| 伊人久久大香线蕉av不卡| 久久亚洲中文字幕精品一区四| 久久精品中文騷妇女内射| 久久综合给合综合久久| 久久精品国产精品青草app| 亚洲日本va中文字幕久久| 久久婷婷五月综合成人D啪| 亚洲一本综合久久| 国产一区二区三区久久| 九九久久自然熟的香蕉图片| 久久久无码精品亚洲日韩京东传媒| 国内精品久久久久影院网站| 国产精品无码久久综合网| 久久综合综合久久97色| 大伊人青草狠狠久久| 97久久精品午夜一区二区| 久久99精品久久久久久hb无码 | 欧美亚洲国产精品久久久久| 久久国产高清一区二区三区| 久久综合中文字幕| 久久精品成人免费国产片小草|