Character array and an array of strings

First take a look at an example: 

	char str[] = { 'x','2','w' };  // 字符数组
	char str2[] = "x2w";      // 字符串数组 
	printf("%s\n", str);      
	printf("%s\n", str2);

1, an array of characters:

    It has the characteristics of an array.

char str[] = { 'x','2','w' };

2, an array of strings

    It has the characteristics of an array and have some of their own properties.

char str2[] = "x2w";

  The compiler will fill in the last byte '\ 0' (zero value)

3, character pointer

char* str3 = "x2w";

 At this time str3 pointer is constant string, the static area "x2w" stored in the memory;

Published 343 original articles · won praise 57 · Views 200,000 +

Guess you like

Origin blog.csdn.net/jadeshu/article/details/103551686