3.2 Pointers, Structures, and Data Files
1. Pointers
int a = 10; int *p = &a; // 'p' is a pointer to 'a', storing its address. printf("%d", *p); // Dereference 'p' to access the value of 'a': 10
int arr[] = {10, 20, 30}; int *p = arr; // Points to the first element of 'arr'. printf("%d\n", *p); // Output: 10 p++; // Move pointer to the next element. printf("%d\n", *p); // Output: 20
void increment(int *n) { (*n)++; // Increment the value pointed to by 'n' } int main() { int num = 5; increment(&num); // Pass the address of 'num'. printf("%d", num); // Output: 6 return 0; }
2. Structures
3. Unions
4. File Operations
Conclusion
Last updated