Lesson 18 of 23

Pointers: Address-களுடன் வேலைPointers: Working with Addresses

12 min 35 XP

ஒவ்வொரு variable-ம் memory-ல் ஒரு address-ல் இருக்கும். &x அந்த address-ஐத் தரும். Pointer என்பது address-ஐ சேமிக்கும் variable: int *p = &x;. *p அந்த address-ல் உள்ள மதிப்பு (dereference).

Every variable lives at an address in memory; &x gives that address. A pointer is a variable that stores an address: int *p = &x;. *p reads or writes the value at that address (dereferencing).

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

NULL pointer-ஐ dereference செய்தால் (*q) program crash ஆகும் (segmentation fault). பயன்படுத்தும் முன் NULL-ஆ என்று சோதியுங்கள்.

Dereferencing a NULL pointer crashes the program (a segmentation fault). Check for NULL before using a pointer.

Challenge

+35 XP

இரண்டு எண்களைப் படித்து, pointers மட்டும் பயன்படுத்தி (int *pa = &a, *pb = &b) அவற்றின் கூட்டுத்தொகையைக் கணக்கிட்டு, a-ல் அந்தக் கூட்டுத்தொகையை *pa மூலம் சேமித்து print செய்யுங்கள்: Input: 4 9 Output: Sum: 13 a: 13

Read two numbers. Using pointers int *pa = &a, *pb = &b, compute the sum through *pa and *pb, store it back into a through *pa, and print: Input: 4 9 Output: Sum: 13 a: 13

Output Loading C (first time takes a few seconds)
Press Run to see the result here.