switch error

A

ampeloso

Hello,
I am compileing a project and I get multiple errors in my switch
statements "illegal case"
Here is some code that looks OK to me.I get an error for eaxh case
These are all ansi c using VS 2005 compiler.

for (i= 1; i < (argc - 1); i++)
{
switch (argv[0])
{
case '-':
switch (argv[1])
{
case 'h':
case 'H':
showHelp(); /* Show help screen and */
return(1); /* exit program. */
break;
case 'c':
case 'C':
memcpy(comPortName, &argv[2], strlen(argv)-2);
break;
case 'p':
case 'P':
passwdFile= &argv[2];
break;
case 'w': case 'W':
toDo.Wait= 1; /* Do wait for <Enter> at the end! */
break;
case '1':
toDo_OnePass= 1;
break;
case 'f':
case 'F':


Thanks
Mike
 
W

Walter Roberson

I am compileing a project and I get multiple errors in my switch
statements "illegal case"
Here is some code that looks OK to me.I get an error for eaxh case
for (i= 1; i < (argc - 1); i++)
{
switch (argv[0])
{


You start that 'switch' statement but never end it. There is no
corresponding '}'
case '-':
switch (argv[1])
{


You start that nested 'switch' statement but never end it. There
is no corresponding '}'


With two missing } then you should expect lots of compile errors.
 
K

Keith Thompson

I am compileing a project and I get multiple errors in my switch
statements "illegal case"
Here is some code that looks OK to me.I get an error for eaxh case
These are all ansi c using VS 2005 compiler.

for (i= 1; i < (argc - 1); i++)
{
switch (argv[0])
{
case '-':
switch (argv[1])
{
case 'h':
case 'H':
showHelp(); /* Show help screen and */
return(1); /* exit program. */
break;
case 'c':
case 'C':
memcpy(comPortName, &argv[2], strlen(argv)-2);
break;
case 'p':
case 'P':
passwdFile= &argv[2];
break;
case 'w': case 'W':
toDo.Wait= 1; /* Do wait for <Enter> at the end! */
break;
case '1':
toDo_OnePass= 1;
break;
case 'f':
case 'F':


This is a code fragment. It cannot be compiled by itself, and it
refers to several things that are not declared within the fragment (i,
argv, showHelp, etc.). We can't guess what might be wrong with the
surrounding code.

If you'll show us a complete program that exhibits the problem, we can
probably help. Trim your program down to a reasonable size before
posting it.

And *please* indent properly; with everything left-justified like
this, it's very difficult to read. (If you used tabs for indentation,
please expand them to spaces before posting; some news software
doesn't like tab characters.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,182
Latest member
BettinaPol

Latest Threads

Top