#include <stdio.h> int main (void) { int answer, result; answer = 100; result = answer - 10; printf ("The result is %i\\n", result + 5);
#include <stdio.h> int main (void) { char c, d; c = 'd'; d = c; printf ("d = %c\\n", d);
#include <stdio.h> int main (void) { intdollars, cents, count; for ( count = 1;count <= 10;++count ) {
当增量运算符放在变量的左侧时,它将首先将变量的值增加1,然后在表达式中使用它。
什么是输出?使用printf()打印的内容可以叫作输出。 #include <stdio.h> int main()
转义序列\\n告诉程序添加一个新行。看看以下程序声明。下表描述了一些常见的转义序列。
以下代码段生成三个单独的行,只有一个printf()函数。 #include <stdio.h> int main(){
\\t转义序列对格式化输出很有用。以下代码在输出中创建列。 #include <stdio.h>
转义序列\\r将光标移动到行的开头。 #include <stdio.h> int main() { printf("This escape sequence moves the cursor ");
#include <stdio.h> int main() { char name[20]; char color[20]; printf("What is your name?");
#include <stdio.h> #include <stdlib.h> int main() { int age; char years[8]; printf("How old was James?");
#include <stdio.h> #include <stdlib.h> int main() { int methus; int you; char years[8]; printf("How old are you?");
#include <stdio.h> #include <stdlib.h> int main() { int diff; int methus; int you; char years[8];
#include <stdio.h> #define SIZE20// Max characters in a word void try_input(char *prompt, char *format);// Input test function
#include <stdio.h> int main(void){ int i = 0; int j = 0; int value_count = 0; float fp1 = 0.0f; printf("Enter: fp1 = 3.14159 i = 7 8\\n");
#include <stdio.h> int main(void) { float fp1 = 0.0f; float fp2 = 0.0f; float fp3 = 0.0f; int value_count = 0;
#include <stdio.h> int main(void) { int i = 0; int j = 0; int k = 0; int n = 0; printf("Enter three integer values:");
#include <stdio.h> #define MAX_TOWN 10 int main(void) { char initial = ' '; char name[80] = { ' ' };
#include <stdio.h> int main(void) { char initial[3] = {' '}; char name[80] = {' '};
操作 必需的控制字符串 读取short类型的值 %hd 读取int类型的值 %d 读取long类型的值
#define MESG "this is a test" #include <stdio.h> int main(void) { int n = 0; while ( n < 5 )
#include <stdio.h> #define SEC_PER_MIN 60// seconds in a minute int main(void){ int sec, min, left;
#include <stdio.h> #include <string.h>/* provides strlen() prototype */ #define PRAISE "this is a test test test test."
转换 输出规范 %a 浮点数,十六进制数和p符号(C99/C11)。 %A 浮点数,十六进制数和P符号(C99/C11)。
标志 含义 - 该项目是左对齐的; 也就是说,它从字段的左侧开始打印。 示例:“%- 20s”。
$gcc -o main *.c $main 212 F is water's boiling point. The printf() function printed 32 characters.
#include <stdio.h> int main(void) { printf("line 1 "); printf("line 2.\\n"); printf("Here's another way to print a \\
#include <stdio.h> int main(void) { float height; char name[40]; printf("Enter your height in inches: ");
#include <stdio.h> int main( void ) { int i1;//fromw ww .java2 s .com int i2; long l1; double d1; char buf1[80];
#include <stdio.h> int main( void ){ char lname[257], fname[257]; int count, id_num; puts("Enter last name, first name, ID number separated \\n");