switch() function in C

I have a problem when I compile my C code under Linux. I'm using Linux Mandrake 7.2 (Odyssey) but I forgot the kernel version (sorry..), and I try to make a program that have a multiple choice. I have using C for a long time but I used it in DOS environment. When I move to C under Linux, I think that it will be similar. Yes, it really similar, but programming in Linux is quite hard. When I want to make a multiple choice in C under DOS, I use switch() function. And it works. But when I use switch() function in C under Linux, and I compile it, it says: "Segmentation Fault" and it refers to the line contains switch() function. How can I correct this error?

Comments

  • : I have a problem when I compile my C code under Linux. I'm using Linux Mandrake 7.2 (Odyssey) but I forgot the kernel version (sorry..), and I try to make a program that have a multiple choice. I have using C for a long time but I used it in DOS environment. When I move to C under Linux, I think that it will be similar. Yes, it really similar, but programming in Linux is quite hard. When I want to make a multiple choice in C under DOS, I use switch() function. And it works. But when I use switch() function in C under Linux, and I compile it, it says: "Segmentation Fault" and it refers to the line contains switch() function. How can I correct this error?
    :
    :

    C-standard is same in DOS and Linux and on all other platforms. There must be something wrong with your switch statement.

    btw. switch isn't a function, it reserved word in C.
  • I have to agree with WEICCO, it's something in your code not the switch itself, post a copy of that section of code if you want and I'll look through it if you havn't found it already.

    Good luck
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories