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

            統(tǒng)計

            留言簿(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麻豆色欲| 久久久久久综合网天天| 99麻豆久久久国产精品免费| 99re这里只有精品热久久| 99久久久久| 欧美激情一区二区久久久| 国产精品美女久久久久久2018| 久久精品国产亚洲Aⅴ香蕉 | 国产精品无码久久综合网| 久久婷婷色综合一区二区| 无码AV波多野结衣久久| 国产成人久久精品二区三区| 久久亚洲精品无码VA大香大香| av无码久久久久不卡免费网站| 久久亚洲AV无码西西人体| 72种姿势欧美久久久久大黄蕉| 婷婷久久五月天| 国产女人aaa级久久久级| 亚洲AV日韩精品久久久久久| 精品久久久久久无码免费| 97久久国产亚洲精品超碰热| 久久成人国产精品免费软件| 亚洲一本综合久久| 国产一区二区三区久久| 欧美牲交A欧牲交aⅴ久久| 精品久久久久久无码不卡| 久久亚洲电影| 久久夜色精品国产www| 精品久久久久中文字| 久久国产成人精品麻豆| 99精品久久精品一区二区| 久久综合给久久狠狠97色| 久久天天躁狠狠躁夜夜躁2014| 理论片午午伦夜理片久久| 精品久久久久中文字| 国内精品免费久久影院| 久久久精品日本一区二区三区 | 97精品国产97久久久久久免费 | 狠狠色丁香久久综合婷婷| 99精品国产在热久久| 国产午夜精品理论片久久影视|