473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

switch error

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

Aug 21 '06 #1
2 1635
In article <11**********************@75g2000cwc.googlegroups. com>,
<am******@gmail.comwrote:
>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[i][0])
{
You start that 'switch' statement but never end it. There is no
corresponding '}'
>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
Aug 21 '06 #2
am******@gmail.com writes:
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) ks***@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.
Aug 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Christopher Benson-Manica | last post by:
Can you goto switch labels? int i=0; /* arbitrary */ switch( i ) { case 0: if( !some_validity_check() ) { goto error; /* could be default as well */ } /* proceed normally */
8
by: Sivas | last post by:
Hi, Can anyone tell me why this does not work: --------------------------------------------- float b = 2.51F; switch(b) {
13
by: Adam Blair | last post by:
Is it possible to bind a switch statement to an Enum such that a compile-time error is raised if not all values within the Enum are handled in the switch statement? I realise you can use default:...
27
by: Yuriy Solodkyy | last post by:
Hi VS 2005 beta 2 successfully compiles the following: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
14
by: serrand | last post by:
Could someone tell me a beautiful way to exit from a switch and a loop in one statement ... without using a goto... and if possible without using an auxiliary variable as i did... int res;...
11
by: Peter Kirk | last post by:
Hi i have a string variable which can take one of a set of many values. Depending on the value I need to take different (but related) actions. So I have a big if/else-if construct - but what is...
4
by: huzzaa | last post by:
I am using a switch statement that will decide from a random number what message to display. I want the random number to be between 0 and 100 and then if the number is say between 1 and 10 to...
6
by: asadikhan | last post by:
Hello, I have a bit of a design issue around this application I am developing, and I just want to run it through some of the brains out here. So I have a table called ErrorCheck which...
2
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of...
7
by: Rohit | last post by:
Hi, I am working on a switch module which after reading voltage through a port pin and caterogizing it into three ranges(open,low or high), passes this range to a function switch_status() with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.