A whole bunch of Segmentation Faults

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2006
Posts: 2,033
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic
 
1
  #11
21 Days Ago
Originally Posted by thure View Post
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.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC