|
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++; } } |
原文:http://www.cnblogs.com/l-jiang/p/3579295.html