linux下C语言三种get输入方式

 

第一种:scanf()

#include "stdio.h"
#include "string.h"

int main() { char name[10]; scanf("%s", name); puts(name); return 0; }

 

第二种:fgets()

#include "stdio.h"
#include "string.h"
int main() { char name[10]; fgets(name, 10, stdin); puts(name); return 0; }

 

第三种:getchar()

#include "stdio.h"

int main()
{
 char name;
 name=getchar();
 printf("%c",name); 
 return 0;

}

 

自己也是初学者,肯定说的不怎么正确

 http://frank-dev-blog.club/?post=2

posted @ 2018-09-01 16:50  Z_Chan  阅读(1067)  评论(0编辑  收藏  举报