c语言中,printf,print,input,都表示输出,他们有啥区别

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c语言中,printf,print,input,都表示输出,他们有啥区别相关的知识,希望对你有一定的参考价值。

print--是函数,可以返回一个值,只能有一个参数。用起来最简单

printf--函数,把文字格式化以后输出,直接调用系统调用进行IO的,他是非缓冲的。

input--是从指定的已经打开的文件里面读取。

如:
$name="hunte";
$age=25;
printf("my name is %s, age %d", $name, $age);

sprintf--跟printf相似,但不打印,而是返回格式化后的文字,其他的与printf一样。
如:
char sql[256];
sprintf(sql,"select * from table where no = '%s'",bankno);
它的功能只是把""里面的语句赋给了变量sql。

参考技术A printf是c的一个库函数,而print和input都不是吧!只是后两个我们常习惯用来作为自己定义的函数的名称!应该是这样吧! 参考技术B printf() 是标准输出 ,输出在stdout上
input()是从指定的已经打开的文件里面读取
print()....不知道...好像没有吧
参考技术C C语言中标准函数只有printf是输出吧.
print和input都不是C的标准函数,input从名字上看是输入而不是输出.
参考技术D printf(“”);是输出函数
print 应该是输出打印的意思
input()调用输入

c语言 编写输入函数input和打印函数print,用来输入和打印一个学生的基本信息。该数组中有

c语言 编写输入函数input和打印函数print,用来输入和打印一个学生的基本信息。该数组中有5个学生的数据记录,每个记录包括学号num、姓名name、成绩score[3],从主函数调用input函数输入这些记录,用print函数输出这些记录。

typedef struct _stu
char name[100];
int num,score[3];
stu;
stu input()
stu s;
printf("input name");
scanf("%s",s.name);
printf("input number");
scanf("%d",s.num);
printf("input 3 scores");
scanf("%d,%d,%d",s.score,s.score+1,s,score+2);
return s;

void print(stu s)

printf("%d\t%s\t%d,%d,%d",s.num,s.name,s.score[0],s.score[1],s.score[2]);

main()

stu a;
a=input();
printf("num\tname\tscore\n");
print(a);
追问

typedf struct什么意思看不懂

追答

#include
typedef struct _stu

char name[100];
int num, score[3];
stu;
stu input()

stu s;
printf("input name");
scanf("%s", s.name);
printf("input number");
scanf("%d", &s.num);
printf("input 3 scores");
scanf("%d,%d,%d", s.score, s.score + 1, s.score + 2);
return s;


void print(stu s)

printf("%d\t%s\t%d,%d,%d", s.num, s.name, s.score[0], s.score[1],
s.score[2]);


main()

stu a;
a = input();
printf("num\tname\tscore\n");
print(a);

追问

厉害。厉害。

谢谢喽

追答

定义学生结构体

追问

(⊙o⊙)哦(⊙o⊙)哦

谢谢

为什么我打出来有6个

错误。。

参考技术A #include<stdio.h>
struct student

char num[20];
char name[20];
int score;
;
struct student students[5];

void input(student students[],int n)

int i;
for(i=0;i<n;i++)

scanf("%s,%s,%d",&students[i].num,&students[i].name,&students[i].score);



void print(student students[],int n)

int i;
for(i=0;i<n;i++)

printf("%s,%s,%d",students[i].num,students[i].name,students[i].score);



int main()


input(students,5);
print(students,5);
return 0;
参考技术B 用结构体追问

可以编写出来吗?谢谢啦!

追答

等等

追问

看不清。。大哥

追答

我电脑打不开 只能手写 哪里看不清

等等 我换台电脑

追问

谢谢

追答

input和print没什么人用吧

😱抱歉你的题目需要自定义函数 我没看清。你把那两个拖进自定义函数就可以了。需要我帮重发一次吗

追问

谢谢啦

么么哒

以上是关于c语言中,printf,print,input,都表示输出,他们有啥区别的主要内容,如果未能解决你的问题,请参考以下文章

c语言中两句相同的printf为啥输出结果不同

c语言中printf与p r i n t f有啥区别

printf的读音

print、printf、println的区别

print、printf、println的区别

c语言一个关于printnum的问题