944,161 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 806
  • C RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Nov 11th, 2009
1
Re: A whole bunch of Segmentation Faults
Click to Expand / Collapse  Quote originally posted by thure ...
Aw man, I thought C handled chars! It's just one byte! Okay, thanks again for your help.

As a general rule, do segmentation faults happen because memory isn't allocated? I'd guess with beginner C it wouldn't be anything fancier.
segmentation faults occur when you are trying to access memory that you are not suppose to. e.g.
  1. int *x; /* declares a pointer to int, the variable x is holding a random value which will be used to represent an address */
If you don't make that x to point to something meaningful, who knows what that random value is going to try to represent, and access as an address. Accessing that random address to write into, can create a segmentation fault.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Error while declaring a structure
Next Thread in C Forum Timeline: delete same array element in C





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC