if语句,while语句,指针,结构体
一、字符串+转义字符+注释
1、由双引号(Double Quote)引起来的一串字符称为字符串字面值(String Literal),或者简称字符串。字符串的结束标志是一个 \0 的转义字符。在计算字符串长度的时候 \0 是结束标志,不算作字符串内容。
//本程序说明'\0'很重要
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
char arr1[] = "abcd";
char arr2[] = {
'a', 'b', 'c' ,'d'};
char arr3[] = {
'a', 'b', 'c' ,'d','\0'};//'\0'可以写为'0',因为'\0'的ASCLL码值为0
printf("%s\n", arr1);//字符串输出用%s,可以看到输出结果为abcd
printf("%s\n", arr2);//输出结果不确定,但必有abcd
printf("%s\n", arr3);//可以看到输出结果为abcd
return 0;
}
2、转义字符:转变符号的意思
引例:加入我们要在屏幕上打印一个目录: c:\code\test.c
#include <stdio.h>
int main()
{
printf("c:\code\test.c\n");
return 0; }
但输出结果如下图,
这是因为\t被转义了,需要解决可以在\t前再加一个\
#include <stdio.h>
int main()
{
printf("c:\\code\\test.c\n");
return