![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why not a segmentation fault?? | lagigliaivan | High Level Programming | 22 | 05-21-2008 08:07 AM |
| segmentation fault | rockgal | High Level Programming | 8 | 12-05-2006 09:16 AM |
| Segmentation Fault | compbug | UNIX for Dummies Questions & Answers | 3 | 04-21-2006 07:43 AM |
| Segmentation fault | jshaulis | AIX | 1 | 06-01-2004 01:16 PM |
| segmentation fault | omran | High Level Programming | 2 | 08-01-2003 05:19 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
segmentation fault
sometimes for this code i get a segmentation fault for codes llike this
: int main{ int * a= 0; int b; a = (int*)malloc(sizeof(int)); ///some code using these variable but no freeing of a if(a){ free(a); a = 0; } return 0; } |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
The problem is probably in the code you did not post. But I will mention that malloc will fail if the data segment has maxed out. I don't see you test for that. You'll get a null pointer with errno set to ENOMEM. Dereferencing a null pointer can cause a seg fault on some architectures.
|
|
#3
|
|||
|
|||
|
thank you
thanks buddy your a gr8 help but will trouble you later for more queries
eg something like this waiting . . . . . code is int i; for(i =0;i < 10;i++){ printf(" ."); //command i'm loooking which waits for(say 300 ms) (works in linux not windows) } printf("\n"); plz reply thanx |