& एक संख्या है जो एक रैल्यू है: यदि आप एक वैरिएबल में चाहते हैं तो आप इसे कहीं भी स्टोर कर सकते हैं, जिसे आपने int * टाइप किया है या आवंटित किया होगा।
बुद्धि के लिए
:
int a = 42;
&a; /* this does not store the address of a because you've not assigned the value to a variable */
int **aptr = &a; /* aptr is on the stack */
int **aptr2 = (int*)malloc(sizeof(int*));
aptr2 = &a; /* aptr2 is in the heap */
& (& क) कानूनी सिंटैक्स नहीं है। आप किसी पूर्णांक पर एक सूचक के लिए सूचक चाहते हैं:
int b = 39;
int *bptr = &b;
int **ptr2bptr = &bptr;
आप अविवेक के स्तर का निर्माण करने के लिए है।
के साथ आप ऊपर तो यह कर सकते हैं अगर आप चाहते हैं:
printf("%d\n", *aptr);
printf("%d\n", *aptr2);
printf("%d\n", *bptr);
printf("%d\n", **ptr_to_bptr);
के उत्पादन उत्पादन:
42
42
39
39
स्रोत
2009-07-10 14:40:27
करने के लिए कुछ वैध स्मृति का पता असाइन, को यह जवाब बाहर की जाँच करें: http://stackoverflow.com/questions/991075/does-a-pointer-also-have-any-address-or-memory-allocation/991152#991152 –
यहां भी: http://stackoverflow.com/questions/96285/in- सीआई-कैन-ग्रिप-पॉइंटर्स-एंड-क्लासेस/98525 # 9 8525 –