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

            久久久久国产| 国内精品九九久久久精品| 国产精品久久久久久久久久免费| 国产精品久久久久久福利漫画| 色综合久久88色综合天天| 久久精品国产亚洲一区二区三区| 国产精品熟女福利久久AV| 香蕉久久永久视频| 996久久国产精品线观看| 久久99国产精品成人欧美| 一本色道久久综合狠狠躁| 麻豆精品久久精品色综合| 99久久这里只精品国产免费| 欧美午夜精品久久久久免费视| 久久国产高清字幕中文| 2021国内久久精品| 精品无码久久久久久久动漫 | 成人综合伊人五月婷久久| 999久久久国产精品| 天堂久久天堂AV色综合 | 久久无码专区国产精品发布| 99精品国产在热久久无毒不卡| 麻豆久久| 久久精品视屏| 99久久综合国产精品二区| 久久男人Av资源网站无码软件| 久久精品国产欧美日韩| 国内精品久久九九国产精品| 人人狠狠综合久久88成人| 久久综合亚洲色一区二区三区| 久久久受www免费人成| 国产成人AV综合久久| 久久久久久综合一区中文字幕| 9久久9久久精品| 久久综合久久综合九色| 久久香蕉综合色一综合色88| 高清免费久久午夜精品| 久久久久久狠狠丁香| 91性高湖久久久久| 久久精品亚洲精品国产欧美| 久久国产成人精品国产成人亚洲|