This site works best with JavaScript enabled
Sign In
Discussions
Activity
Sign In
All
Project.001: C Programming, Data Structures
Issues, queries and suggestions related to C, C programming, data structures using C and C based projects.
Project.001: C Programming, Data Structures
Session.08.Introduction to Pointers and References
spatlou
October 2019
Pointers.
spatlou
May 2020
mohitvaishnav962
July 2020
#include<stdio.h>
int main()
{
int *ptr = NULL, x = 3;
//it'll print address = 0
fprintf(stdout, "ptr = %d\n", ptr);
//it'll print ptr = 3
ptr = &x;
fprintf(stdout, "ptr = %d\n", *ptr);
*ptr = 5;
//it'll print ptr = 5
// print x = 5
fprintf(stdout, "ptr = %d\n"
"x = %d\n", *ptr, x);
// *ptr = 3; null pointer assignment error, trying to access the 0th
// location, as 0th location is reserved and is in the
// operating system address space/kernal space
// and user space's program is not allowed to access it,
// its a run time error and a serious one!
return 0;
}
/*
* usage : execute with *ptr = 3 only
* to generate a signal SIGSEGV (segmentation fault).
* Comment the rest, otherwise rest is merely the basic usage of a pointer and the way to bypass this error.
* */
Add a Comment
Powered by
Vanilla
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
0
Module.101: Advanced Data Structures using C
16
Module.303: Linux System Programming
32
Project 22. Ethernet Network Device Driver Development
0
Project.14. Linux System and Network Administration
0
Project.10. Embedded Linux ARM, Configuring and Porting using Storage
0
Project.203 Linux System Programming. MySQL
0
Pravjot Sir Classes
108
Events at EmbLogic
2
Query
503
Module.000: Linux System Administration
21
Project.001: C Programming, Data Structures
74
Project.002: OOPs, C++, Eclipse, Linux
17
Project.003: Linux System Programming
31
Project.004: Linux Network Programming
7
Project.005: Character Device Drivers Development
16
Project.105: Parallel Port Device Drivers Development
5
Project.205: Serial Port Device Drivers Development
3
Project.008: Block Device Driver Development
3
Project.009: Embedded Linux-ARM. Storage
6
Module.011: Shell Scripting using Bash
6
Project 12: Linux Kernel Architecture and Internals
2
Project.015: Python with Eclipse on Linux
2
Project 16: SPI Device Driver Development
2
Project 17: I2C Device Driver Development
0
Project 18: PCI Device Driver Development
0
Project 19: Embedded Linux on ARM Using Network TFTP
0
Project 20: CAN Bus Protocol and Driver Development
0
Project 21: USB Device Drivers Development
0
Embedded Linux
0
ARM Embedded Processor
0
Training
2
Members Area
1
Word From Admin
1