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

            国产精品成人久久久| 丁香五月综合久久激情| 青青久久精品国产免费看| 亚洲精品国产综合久久一线| 久久无码AV一区二区三区| 日产精品久久久久久久| 综合人妻久久一区二区精品| 久久久国产乱子伦精品作者| 精品少妇人妻av无码久久| 国产精品99久久精品爆乳| 色婷婷久久综合中文久久蜜桃av| 国产午夜精品久久久久九九电影| 久久一日本道色综合久久| 国产精品久久久久蜜芽| 亚州日韩精品专区久久久| 久久国产福利免费| 久久久久亚洲AV无码永不| 久久99热这里只频精品6| 97精品伊人久久大香线蕉| 99久久超碰中文字幕伊人| 中文精品99久久国产 | 伊人热热久久原色播放www| 久久久久亚洲AV片无码下载蜜桃| 无码人妻少妇久久中文字幕 | 很黄很污的网站久久mimi色 | 久久国产欧美日韩精品| 国产成人久久久精品二区三区 | 综合人妻久久一区二区精品| 久久久久女教师免费一区| 久久被窝电影亚洲爽爽爽| 久久亚洲AV成人出白浆无码国产| 久久久久亚洲av成人网人人软件 | 久久国产香蕉一区精品| 亚洲精品国产成人99久久| 狠狠干狠狠久久| 国产精品99精品久久免费| 久久亚洲精品成人AV| 97热久久免费频精品99| 久久国产精品-国产精品| 久久99国产精品久久久| 久久久国产精品福利免费|