Connecting Tech Pros Worldwide Forums | Help | Site Map

switch error

ampeloso@gmail.com
Guest
 
Posts: n/a
#1: Aug 21 '06
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[i][0])
{
case '-':
switch (argv[i][1])
{
case 'h':
case 'H':
showHelp(); /* Show help screen and */
return(1); /* exit program. */
break;
case 'c':
case 'C':
memcpy(comPortName, &argv[i][2], strlen(argv[i])-2);
break;
case 'p':
case 'P':
passwdFile= &argv[i][2];
break;
case 'w': case 'W':
toDo.Wait= 1; /* Do wait for <Enterat the end! */
break;
case '1':
toDo.OnePass= 1;
break;
case 'f':
case 'F':


Thanks
Mike


Walter Roberson
Guest
 
Posts: n/a
#2: Aug 21 '06

re: switch error


In article <1156177015.983822.215770@75g2000cwc.googlegroups. com>,
<ampeloso@gmail.comwrote:
Quote:
>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
Quote:
>for (i= 1; i < (argc - 1); i++)
>{
>switch (argv[i][0])
>{
You start that 'switch' statement but never end it. There is no
corresponding '}'
Quote:
>case '-':
>switch (argv[i][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.
--
Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us. -- Ecclesiastes
Keith Thompson
Guest
 
Posts: n/a
#3: Aug 21 '06

re: switch error


ampeloso@gmail.com writes:
Quote:
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[i][0])
{
case '-':
switch (argv[i][1])
{
case 'h':
case 'H':
showHelp(); /* Show help screen and */
return(1); /* exit program. */
break;
case 'c':
case 'C':
memcpy(comPortName, &argv[i][2], strlen(argv[i])-2);
break;
case 'p':
case 'P':
passwdFile= &argv[i][2];
break;
case 'w': case 'W':
toDo.Wait= 1; /* Do wait for <Enterat 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.)

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Closed Thread