Home > Back-end >  How to understand the following passage, brothers
How to understand the following passage, brothers

Time:04-14

Use string constants in program generates a pointer to the character constants, when a string constants in an expression, the expression of the value is used by these characters stored address, rather than the characters themselves,

CodePudding user response:

If there is any example, brothers

CodePudding user response:

For example:
 const char * STR="helloworld";//this assignment (=) the value of the expression is a string constant address assigned to the STR 

CodePudding user response:

Consider this:
 printf (" % s \ n ", "abcdef" + 1); 

It is the output of the
Bcdef
That means what?

CodePudding user response:

reference 2 building self-confidence boy reply:
such as:
 const char * STR="helloworld";//this assignment (=) the value of the expression is a string constant address assigned to the STR 

Understand, thank you brother

CodePudding user response:

reference 2 building self-confidence boy reply:
such as:
 const char * STR="helloworld";//this assignment (=) the value of the expression is a string constant address assigned to the STR 

Such as char * a="helloworld";
Printf (" % s ", a);//output helloworld
Printf (" % d ", a);//output is address
Mean for the helloworld this string specifies an address, this address is called a (is actually a string of Numbers, a just individual name), the other address is the address of the first character string h

CodePudding user response:

Such as char * a="helloworld";
Printf (" % s ", a);//output helloworld
Printf (" % d ", a);//output is address
Mean for the helloworld this string specifies an address, this address is called a (is actually a string of Numbers, a just individual name), the other address is the address of the first character string h

CodePudding user response:

 printf (" % d ", a);//output is address 

Use % p print address;
, the name of this address is called a, the description is wrong, but a is a pointer, put "helloworld" the address of the string in a variable,