首页 > 编程知识 正文

c语言中的结构体如何操作,c语言输出结构体信息

时间:2023-05-03 12:17:10 阅读:286959 作者:3168

c语言 结构体的输入输出

Control Structure in C defines how the statements in the program are going to execute. A statement is a single line or instruction in a program.

C中的控件结构定义了程序中的语句将如何执行。 语句是程序中的单行或指令。

C语言的控制结构 (Control Structure in C)

Control Structure, also known as Control Flow tells that in which order each statement is going to execute. We will discuss following types

控制结构(也称为控制流)告诉您每个语句将以什么顺序执行。 我们将讨论以下类型

Sequential Flow

顺序流

It says that statements are executed in sequence order and each statement is executed exactly once.

它说语句按顺序执行,每个语句只执行一次。

Conditional Flow

条件流

In Conditional Flow, whether execution of particular statement(s) happens or not is dependent on other statement that specifies a condition.
if, if-else, switch

在条件流中,是否执行特定语句取决于指定条件的其他语句。
如果,如果-否则,切换

Iterative Flow

迭代流

The flow by which user can execute particular statement(s) number of times without rewriting them, also known as Looping statements.
for, while, do-while

用户可以执行多次特定语句而不重写它们的流程,也称为循环语句。
暂时

Jump Statements

跳转语句

These are statements to interrupt the flow and move to other statement as per requirement.
break, continue, goto, return

这些语句可中断流程并根据需要移至其他语句。
休息,继续,转到,返回

用C输入和输出 (Input and Output in C)

C programming has multiple ways to take input and output. In our context, Input is something which user enters from keyboard and Output is the result or outcome shown by the program on console (Command prompt/Terminal).
We will discuss 2 functions, printf() for the output and scanf() for the input.
Basically functions are like workers which perform a specific task when they are used.

C编程具有多种获取输入和输出的方式。 在我们的上下文中,Input是用户从键盘输入的内容,Output是控制台上程序(命令提示符/终端)显示的结果或结果。
我们将讨论2个函数, printf()用于输出, scanf()用于输入。
基本上,功能就像工作人员在使用时执行特定任务一样。

printf-scanf

打印扫描

打印 (printf)

Parameters are passed to printf() to show output on the console in the following way.

参数通过以下方式传递到printf(),以在控制台上显示输出。

Strings

弦乐 //String Output. "n" is used for next line.printf("Hello World");printf("n");printf("Hello World in next Line"); integer, character, float/double values

整数,字符,浮点/双精度值 //To print int, "%d" is usedint a = 10;printf("%d",a);printf("n") \Next Line//To print char, "%c" is usedchar ch = 'f';printf("%c",ch);printf("n") \Next Line//for double and float, %f is useddouble d = 10.564;printf("%f",d); 扫描 (scanf)

It takes input from user by keyboard and assigns it to a variable (identifier). Detailed understanding of scanf() is related to “Pointers in C” which is an advanced topic.
Here & is “AddressOf” operator, and scanf(“%d”,&a) means something like “take the value from keyboard, consider it integer (as %d is for int) and put it on the address of a“.

它通过键盘从用户那里获取输入并将其分配给变量(标识符)。 对scanf()的详细了解与“高级C语言指针”有关。
这里是“AddressOf”操作符,和scanf(“%d”,&a)指像“从键盘取值,考虑它的整数(如%d是INT),并把它地址 ”。

//int inputint a;printf("Enter a value of a: ");scanf("%d",&a); //It would prompt user to enter a valueprintf("Value of a is %d",a);//char inputint ch;printf("Enter a value of ch: ");scanf("%c",&ch); //It would prompt user to enter a valueprintf("Value of a is %c",ch); 用C发表的评论 (Comments in C)

Comments help us in providing information about the code statements. The compiler ignores the comments while compilation. Let’s see how to provide comments in C programming.

注释有助于我们提供有关代码语句的信息。 编译时编译器将忽略注释。 让我们看看如何在C编程中提供注释。

“//” (Double slash) for single line comment

单行注释的“ //”(双斜杠) ” /* …..Some lines of comment here….. */ ” for multi-line comments.

” / *…..此处有一些注释行….. * /”用于多行注释。 /*This is Multi-Line Comment.Comments are ignored by the compiler.*///This is a single line Commentint a = 10; //Declaring an integer variable and assigning value as 10; 苏马里 (Sumary)

We have covered up the conceptual understanding of control structure and Input-output in programming. It is important to understand the basic usage before going into the specific cases explained in further articles.

我们已经掩盖了编程中对控制结构和输入输出的概念理解。 在深入探讨后续文章中介绍的特定情况之前,了解基本用法非常重要。

翻译自: https://www.journaldev.com/27891/control-structure-input-output-in-c

c语言 结构体的输入输出

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。