Home > Back-end >  Consult a problem bothering me for a long time
Consult a problem bothering me for a long time

Time:12-05

Because it is in the learning phase

Under the existing code troublesome everybody a great god see

Such as char a [256]
The meaning of this sentence is to create a have a 256 element array,
For example char a [2]={1, 2} like char b [2] you mean difference to assignment 2 element b didn't assign all the initial value is 0

Understand right here

Char a [256]
Then float e=1254.15
Sprintf_s (a, "% 3.4 f", e); Here I can understand the scope of the results is first get e data to remove the decimal point 1254

On the left side of the a is really do not understand how the 1254 assigned to its

Because I understand is like a [256] 256 parameters to assignment is a [1]=1254 equals 1254 assignment to a the first element of the array,

But the sprintf_s (a, "% 3.4 f", e) is really puzzled problems great god shows the following thank you very much!





CodePudding user response:

Char a [256], this is an array, when the string to use, such as:
Char a []="hello world";

CodePudding user response:

You this is the very basic question, the estimate is also did not learn a pointer that piece
If you are to write the data type int inside, the front must be '& amp; 'address symbols, like
Int a=0;
Sprintf_s (& amp; A, "% 3.4 f", e);

Now is actually inside directly into a array is the same, a representative of the array is a address, is also the address of the array a first element, such as a [10]={' 1 ', '4', '6'} then * a is 1
* (a + 1 to 4, because a + 1 represents a second element array address

The problem you said is actually of value of the first address to a element

CodePudding user response:

refer to the second floor I keep was reply:
you this is the very basic question, estimation is also did not learn a pointer that piece
If you are to write the data type int inside, the front must be '& amp; 'address symbols, like
Int a=0;
Sprintf_s (& amp; A, "% 3.4 f", e);

Now is actually inside directly into a array is the same, a representative of the array is a address, is also the address of the array a first element, such as a [10]={' 1 ', '4', '6'} then * a is 1
* (a + 1 to 4, because a + 1 represents a second element array address

The problem you said actually wrote in my first address to a element values
thank you very much, already understand, just start to contact this place is in the let I didn't force! Ha ha, now see!

CodePudding user response:

In addition, b [2] without initialise the element inside the random number, and is not zero
  • Related