摘要: 删除空格的小程序内容如下。#include <stdio.h>void blankdel (char *str);int main (void){ char str[20] = " ab cd ef "; puts (str); blankdel (str); puts (str); return 0;}void blankdel (char *str){ char *p = str; char *q = str; while (*p) (*p != ' ') ? (*q++ = *p++) : (p++); *q = '\0'; 阅读全文
posted @ 2011-07-23 21:12 jialejiahi 阅读(362) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int wordcnt (const char *str);int main (void){char str[20] = " b cde cd ef ";printf ("%d\n", wordcnt (str));return 0;}int wordcnt (const char *str){int cnt = 0;int flag = 0;//空格则flag标记为0,字符为1while (*str){if ((!isspace (*str)) && (flag == 0)){cnt++; 阅读全文
posted @ 2011-07-23 20:31 jialejiahi 阅读(207) 评论(0) 推荐(0) 编辑