I try to write the following code, through the use of the code I found the address is confusion,
This is the head node, node and linear table definition;
Here to use a local variable in a way that linked list node to add, but rather with the address, the idea is to list the next storage is the address of the next node, code x - l.next=l.net & gt; Next will be the address to cover, so I set up a sequence table to store every node address,
But there appears the question
I don't think there are l.n ext storage is the address of the next node, but the problem so I want to cast to (int *), so does make an error disappear, but I don't know whether to do so effectively, or I will order table that addsize data types into a struct biao *? Address is type int or for each data type the address of the data type is the corresponding relationship, only numerical are hexadecimal number, so storage l.n ext to address needs to be defined struct biao * address? Could I do? Or how should do? Still can't realize?
Here is as can continue downward after storage, compile l.next=l.net X-ray & gt; Next, make l.n ext has been repeated cycle until the last node and then realize inserting new node operation,
Here the scanf (" % c ", & amp; L.n ext - & gt; Why did the date) in l.n ext - & gt; The date before the address-of operator? L.n ext - & gt; The date that in itself is not address?
The last line and the function p.a ddsize=o; Front screenshots first address this is to avoid missing, the last line has a problem,
Use the list again, can only access by linear table stored in the address, so I wrote the assignment, but the system error, I think l.n is an address in the ext but this is not how to cast can you need? Why is that? The storage address, isn't it, but why not int type, I don't think int type should can be cast to struct biao *, how to use the address to access the stored data, have * can access, such as * lite. Next to access (here is based on the int * p=& amp; a; So * p is the value of a vision,
I would like to ask is whether could you tell me the usage of c address, thank you very much, more than useless code inspection because less likely, even out the results don't see why
These are all according to address the problem and imagination, I may not comply with the provisions of the c language, please understand
CodePudding user response:
Confucius said: thought without learning is dangerous,Language is such thing as a standard, invented the is not natural law, the previous ideas in there, thinking alone is not a comprehensive grasp of,
Many materials can guide learning step by step, even if there are such and such shortcomings, it is better to have a textbook to guide two blind ah,
Learn pointer, Pointers and arrays, pointer to the array elements and the pointer to a one-dimensional array -- - the same pointer variable structure of array pointer to a pointer
Then look at function, recursive, variable scope and life cycle - returns the pointer function and a pointer to the function
The above contents in the textbooks when you doubt is,