#include <stdio.h> #include <string.h>
void TestFun(char a[100]) { printf("before addr:%p\n", a); // Printing a Address of
//a = "very good"; // error . String cannot be assigned directly to character array ,a 's address has changed . It is estimated that the system is a Open up new memory space ."very
good" The lifetime of is from the beginning to the end of the process //a[0] = "very good"; // error .a The address of will not change , Can be changed a[0] Value of
strcpy(a, "very well"); // correct
/* a[0] = 'v'; // correct . Assign values one by one a[1] = 'e'; a[2] = 'r'; a[3] = 'y'; a[4] = ' ';
a[5] = 'g'; a[6] = 'o'; a[7] = 'o'; a[8] = 'd'; a[9] = '\0'; */
printf("after addr:%p\n", a); // Printing a Address of printf("%s\n", a); }
int main(void) { char TestStr1[60] = {"abchij"}; char TestStr2[] = {"abchij"};
char TestStr3[100] = {65,66,67};
//strcat(TestStr1 , TestStr2);
printf("main before TestStr3:%s\n", TestStr3); TestFun(TestStr3); printf("main
afterTestStr3:%s\n", TestStr3);

getchar(); return 1; }
stay vs2010 Run results in : main before TestStr3:ABC before addr:003EF7A4 after
addr:003EF7A4 very well main after TestStr3:very well
summary : It can be used { printf("after addr:%p\n", a); // Printing a Address of } To print a pointer , Or the address of the array name .

©2019-2020 Toolsou All rights reserved,
Unity Scene loading asynchronously ( Implementation of loading interface )ESP8266/ESP32 System : Optimize system startup time vue Of v-if And v-show The difference between JS How to operate college examination for the self-taught An overview of Marxism Faster RCNN Explanation of series algorithm principle ( note )CSS architecture design NOI2019 travels IAR Installation and use tutorial sort ( one ) bubble sort