Lesson 18 of 23

Pointers: Addresses ಜೊತೆ ಕೆಲಸ

12 min 35 XP

ಪ್ರತಿ variable memory ಯಲ್ಲಿ ಒಂದು address ನಲ್ಲಿ ಇರುತ್ತದೆ; &x ಆ address ಕೊಡುತ್ತದೆ. Pointer ಎಂದರೆ address ಸಂಗ್ರಹಿಸುವ variable: int *p = &x;. *p ಆ address ನ value ಓದುತ್ತದೆ ಅಥವಾ ಬರೆಯುತ್ತದೆ (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 ಮಾಡಿದರೆ ಪ್ರೋಗ್ರಾಮ್ crash ಆಗುತ್ತದೆ (segmentation fault). Pointer ಬಳಸುವ ಮೊದಲು NULL ಪರಿಶೀಲಿಸಿ.

Challenge

+35 XP

ಎರಡು ಸಂಖ್ಯೆಗಳನ್ನು ಓದಿ. Pointers int *pa = &a, *pb = &b ಬಳಸಿ *pa ಮತ್ತು *pb ಮೂಲಕ ಮೊತ್ತ ಲೆಕ್ಕಿಸಿ, ಅದನ್ನು *pa ಮೂಲಕ ಮತ್ತೆ a ಗೆ ಇಟ್ಟು 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.