Home > Back-end >  Why not add & and []
Why not add & and []

Time:04-17


Figure in the int a [100]; To assign a [100] why the line when the scanf enter inside it without & amp; And []

CodePudding user response:

Other format identifier corresponding variables plus & amp; Is to get the address, and the array name itself is address, add brackets, it is not the address, plus & amp; To gild the lily,

CodePudding user response:

The scanf (" % s ", a) as input a string, not a character, because of the character array name was representing the array to store the first address of the string, so you don't have to add the address-of operator & amp; Behind, also need not square brackets [] points out that the array elements are subscript, hope to adopt

CodePudding user response:

reference 1st floor forever74 response:
other format identifier corresponding variables plus & amp; Is to get the address, and the array name itself is address, add brackets, it is not the address, plus & amp; To gild the lily,
it []

CodePudding user response:

The scanf corresponds to the position of a requirement is the address, and an array of a name is the first address of the array, so there is no need to add & amp;

Your definition of a type is an int array, and to use % s input, type mismatch, although does not affect the program run ~, according to the program logic of the building Lord, should be defined as a char array type;


In addition, the operation of the c=c meaningless, suggest to delete;
  • Related