The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Why not a segmentation fault?? lagigliaivan High Level Programming 22 05-21-2008 12:07 PM
Segmentation Fault compbug UNIX for Dummies Questions & Answers 3 04-21-2006 11:43 AM
segmentation fault wojtyla High Level Programming 3 02-19-2005 02:53 PM
Segmentation fault jshaulis AIX 1 06-01-2004 05:16 PM
segmentation fault omran High Level Programming 2 08-01-2003 09:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-13-2006
vijlak vijlak is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 23
Hi! segmentation fault

I have written a program which takes a directory as command line arguments and displays all the dir and files in it.
I don't know why I have a problem with the /etc directory.It displays all the directories and files untill it reaches a sub directory called peers which is in /etc/ppp/peers.the output stops there and says "segmentation fault".I don't know why I have this problem.Any help is greatly appreciated.Thank you.
  #2 (permalink)  
Old 11-13-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
It might have to do with the string length. We cant comment until we see the code. Or better, compile your code with -g3 -ggdb3 flag and then run it through gdb. That should tell you whats happening.
  #3 (permalink)  
Old 11-13-2006
vijlak vijlak is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 23
Hi

Hi vino!
Thanks for ur quick reply.
I never tried what u said.
Can u tell me in detail?

Last edited by vijlak; 11-13-2006 at 10:48 AM..
  #4 (permalink)  
Old 11-13-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,807
Most C compilers are going to issue errors/warnings with your code. You have some problems.

First suggestion to fix one issue - #include <limits.h>

Usually dealing with full filenames means declare your strings like this with PATH_MAX

Code:
   char mydir[PATH_MAX]={0x0};

Plus, what you're doing is far easier with ftw() - see man ftw
  #5 (permalink)  
Old 11-13-2006
vijlak vijlak is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 23
Hi!

Thanks Jim! Greatly appreciate ur suggetion.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0