熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> 數據結構 >> 正文

編寫代碼實現刪除一個字符串中連續出現超過一次的空格?

2022-06-13   來源: 數據結構 

#include<stdioh> #include<stringh> #include<stdlibh> #define SPACE main() { char string[] *blank *start; int length c = d = ; printf(Enter a string\n); gets(string); length = strlen(string); blank = string; start = (char*)malloc(length+); if ( start == NULL ) exit(EXIT_FAILURE); while(*(blank+c)) { if ( *(blank+c) == SPACE && *(blank+c+) == SPACE ) {} else { *(start+d) = *(blank+c); d++; } c++; } *(start+d)=\; printf(%s\n start); free(start); return ;
From:http://tw.wingwit.com/Article/program/sjjg/201405/30742.html

    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.