C语言练习代码-9

时间:2014-03-04 15:58:55   收藏:0   阅读:448
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 输出给定字符串的每一个字符
*/
#include<stdio.h>
#include<conio.h>
void in1(char *p ,int len);
void out1(char * p);
int main(void)
{
  
 char p[20];
  in1(p,20);
  out1(p);
  getchar();
return 0;
}
 
void in1(char *p ,int len){
     fgets(p,len,stdin);//fgets 会读入换行符 \n,可以使用gets替换,不过要注意gets无法限制输入字符个数。
     }
      
void out1(char * p){
      while(*p !=‘\0‘){
               if(*p !=‘\n‘){//针对使用fgets读入的字符串,
                 putchar(*p);
               }
               p++;
               }
     }

  

C语言练习代码-9,布布扣,bubuko.com

原文:http://www.cnblogs.com/l-jiang/p/3579295.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!