C学习-printf
1.简单介绍
printf 中 print 代表打印 f ,代表format 格式化输出。
所以 printf() 就是代表格式化打印输出
demo-1 如最基本的 hello word 打印功能。
#include <stdio.h>int main(){printf(" hello world!");}
demo-2 打印一个简单的图形
这里的 \n 是转移换行,\n\后面的一个反斜杠只是。下面的字符串延续这个风格。
#include <stdio.h>int main (){printf("\n\*****************\n\* * * * * * *\n\* * * *\n\* * * *\n\* * * * * * *\n\*****************\n\\n");return 0;}
2.几种不同的语言打印出 hello word
C:printf(“hello word”);C++:std::cout << "hello word";C#:System.Console.WriteLine("hello word");Python:print(“hello word”)Java:System.out.println("hello word");JS:console.log(' hello word' );PHP:echo "hello word";
3.C语言转义字符表
| 转义字符 | 意义 | ASCII 码(十进制) |
|---|---|---|
| \a | 响铃(BEL) | 007 |
| \b | 退格(BS) ,将当前位置移到前一列 | 008 |
| \f | 换页(FF),将当前位置移到下页开头 | 012 |
| \n | 换行(LF) ,将当前位置移到下一行开头 | 010 |
| \r | 回车(CR) ,将当前位置移到本行开头 | 013 |
| \t | 水平制表(HT) | 009 |
| \v | 垂直制表(VT) | 011 |
| ‘ | 单引号 | 039 |
| “ | 双引号 | 034 |
| \ | 反斜杠 | 092 |
