LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-26-2008, 09:24 AM   #1
nasim751
Member
 
Registered: Jan 2008
Posts: 40

Rep: Reputation: 15
Post segmentation error (core dumped) Linux in c


hello,
how do u deal this segmentation error (core dumped) after compile program using this commend:
gcc -g -O2 -Wall -o descry descry.o -lpcap -lnet.
see this following main part
int
main(int argc, char *argv[])
{
int c;
u_char flags;
char *device;
char *capture_file;
struct des_pack *gp;
printf("[TCP port scan detection tool]\n");

flags = 0;
device = NULL;
capture_file = NULL;
while ((c = getopt(argc, argv, "afi:vs:h")) != EOF)
{
switch (c)
{
case 'a':
flags |= ALL_HOSTS;
break;
case 'f':
capture_file = optarg;
break;
case 'i':
device = optarg;
break;
case 'v':
break;
case 's':
flags |= DO_SYSLOG;
break;
case 'h':
default:
usage(argv[0]);
return (EXIT_FAILURE);
}
}

Last edited by nasim751; 01-26-2008 at 09:48 AM.
 
Old 01-26-2008, 09:55 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
The only thing wrong (apart from DO_SYSLOG and ALL_HOSTS not defined is this:
Code:
    while ((c = getopt(argc, argv, "afi:vs:h")) != EOF)
    {
        switch (c)
        {
            case 'a':
                flags |= ALL_HOSTS;
                break;
            case 'f':
                capture_file = optarg;   # <== using optarg while no ':' after 'f' in opt-string
                break;
            case 'i':
                device = optarg;
                break;
            case 'v':
                break;
            case 's':
                flags |= DO_SYSLOG;
                break;
            case 'h':
            default:
                usage(argv[0]);
                return (EXIT_FAILURE);
        }
    }
 
Old 01-27-2008, 06:06 PM   #3
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,455

Rep: Reputation: 84
Hya,

Can you also
1. use [code] tag
2. post #include lines
3. spell full and correct English?

Happy Penguins!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
segmentation fault (core dumped) - what??? Micro420 Programming 6 12-07-2006 02:03 AM
Segmentation fault (core dumped) eytan *BSD 3 04-27-2005 09:38 PM
Segmentation Fault (core dumped) newuser455 Linux - Software 3 08-28-2004 03:39 PM
Segmentation fault (core dumped) plisken Linux - General 8 09-17-2003 04:32 AM
Segmentation fault (core dumped) hasanaydin Linux - General 0 03-27-2002 08:47 AM


All times are GMT -5. The time now is 04:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration