I was not qualified to talk about technology as a learner. However, two questions from the csdn Forum C language have made me feel a little technical. So I want to record these records. For your sharing. In this regard, I have raised many of the problems I encountered here. As I have not been able to solve them completely, I have not given any results, we hope to discuss this with you.
Let's take a look at the following code:
Printf ("% F", 10/3 );
What is its big case? We don't have to guess, as long as we run it, we should know that in windows, the result is
0.0000000
I haven't figured out why it is such a result. But we can use it to learn something else. Below are some of the above code I have extended, as shown below:
# Include <stdio. h>
Int main ()
{
Int A = 10/3;
Double B = (double);
Printf ("% u/N", & );
Printf ("% u/N", & B );
Printf ("% d/N", sizeof (INT ));
Printf ("% d/N", sizeof (double ));
Printf ("% F/N", );
Printf ("% F/N", B );
Getchar ();
Return 0;
}
Let's take a look at its results (Dev-C ++ environment compilation ):
Zero X 2293620
Zero X 2293608
4
8
0.0000000
3.0000000
This result shows that there is a problem with data storage. A is allocated from the address 0x2293620. However, there is a problem that B is not allocated immediately after. What is the idle space in the middle? I did not research it out, but I think it should be related to the first location 0.0000000. As for the specific case, I still need to study the authentication.
There is another problem with the above program: Why is the floating point data output by default 8 bits. I cannot solve this problem.
Let's look at another program:
Int main ()
{
Int A = 1;
Int B = 2;
Int array [2] = {3, 4 };
Array [-2] = 5;
Array [-1] = 6;
Printf ("% d, % d", a, B );
Return 0;
}
I think there is no need to give an answer to this question. Here I will post my reply to this question in the Forum (personal opinion only ):
For Windows systems, changing a = 1 and B = 2 will not change. This is related to memory allocation. For the data defined in this question, the first defined data is allocated at a high address, that is, the memory address of a is larger than the memory address of B, the Array Memory is allocated immediately after it is lower than the B address. However, because the windows system uses the defined data as the small-end storage mode, therefore, the memory addresses with array [0] stored in arrays are smaller than the memory addresses of array [1]. In this way, the address sizes are sorted as follows: & array [-2] <& array [-1] <& array [0] <& array [1]. in this way, array [-1] and array [-2] do not change the values stored in A and B.
This is the response. It is the conclusion that I have passed many printf. Even so, I think a little more about it. In fact, it is not just about programming, but it has already involved the computer system structure and memory allocation. After that, I feel that to learn a subject, if you really want to understand it, you must pay attention to its foundation. This is the starting point for us to understand it.