C语言练习代码-9

/*
 输出给定字符串的每一个字符 
*/ 
#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++;
               }
     }

  

posted @ 2014-03-03 21:50  51Joey  阅读(110)  评论(0编辑  收藏  举报