Quantcast
Channel: Segmentation Fault, pointer issue? - Stack Overflow
Browsing index pages (3 articles)
↧

Segmentation Fault, pointer issue?

I'm pretty new to C coding, and pointers are something I'm having a lot of trouble with. I'm trying to write a program that takes in 2 pointers as parameters, adds the value of the first to the second,...

View Article


Answer by HelloWorld123456789 for Segmentation Fault, pointer issue?

In main you have to allocate spaces for x and y before you can use it. If x and y are not allocated spaces, they point to arbitrary memory locations. If they are outside of your program segment, you...

View Article


Answer by Jabberwocky for Segmentation Fault, pointer issue?

This will cause a segfault because you are dereferencing a pointer that has not been initialized. int *x; // declares pointer X *x = 3; // seg fault here because x contains garbage and points certainly...

View Article
Browsing index pages (3 articles)


Latest Images