LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,832

Rep: Reputation: 108Reputation: 108
Hya,

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

Happy Penguins!
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:52 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
Open Source Consulting | Domain Registration