LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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, 08: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 08:48 AM.
 
Old 01-26-2008, 08: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, 05: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,433

Rep: Reputation: 83
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 01:03 AM
Segmentation fault (core dumped) eytan *BSD 3 04-27-2005 08:38 PM
Segmentation Fault (core dumped) newuser455 Linux - Software 3 08-28-2004 02:39 PM
Segmentation fault (core dumped) plisken Linux - General 8 09-17-2003 03:32 AM
Segmentation fault (core dumped) hasanaydin Linux - General 0 03-27-2002 07:47 AM


All times are GMT -5. The time now is 03:27 AM.

Main Menu
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