|
From: Noorez K. <coo...@ho...> - 2004-05-29 05:34:20
|
I am having a problem with the case statement with both the switch
statements in the program.
They are both exactly the same really.... I marked the lines with errors
The compile errors are
[Warning] Infunction 'int main(int, char**)
Line 57/110 Jump to case label
Line 50/103 crosses initialization of 'char intern[16]';
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main(int args, char* pszArgs[])//there needs to be args for this to work
{
if(strcmp(pszArgs[1],"-nt")== 0)
{
system("cls");//start with a clear screen
//explain what the heck all this does
cout << "Welcome to the easy program opener!\n";
cout << "Hear is a list of programs that can be easy opened\n\n";
cout << "To quit enter 0 or nothing for a program choice\n";
cout << "1. Microsoft Office\n";
cout << "2. Microsoft Paint\n";
cout << "3. Calculator\n";
cout << "4. Internet Explorer\n";
int choice;
while(1)
{//while
choice = 0;
cout << "\nEnter the number of your choice: ";
cin >> choice;
switch(choice)
{//switch
case 0:
cout << "Exiting easy opener...\n";
//Sleep(1000);
return 0;
break;
case 1:
system("start winword");
break;
case 2:
system("mspaint");
break;
case 3:
system("calc");
break;
case 4:
char site[123];
char intern[] ="start iexplore "; /*50*/
cout << "Enter site: ";
cin >> site;
strcat(intern,site);
system(intern);
break;
default://the choice wasn't a valid one if we are at default /*line
57*/
cout << "Not a valid choice\n";
}//switch
}//end while
}//done defining nt operating system
if(strcmp(pszArgs[1],"-me")==0)
{
system("cls");
cout << "Welcome to the easy program opener!\n";
cout << "Hear is a list of programs that can be easy opened\n\n";
cout << "To quit enter 0 or nothing for a program choice\n";
cout << "1. Microsoft Office\n";
cout << "2. Microsoft Paint\n";
cout << "3. Calculator\n";
cout << "4. Internet Explorer\n";
int choice;
while(1)
{
cout << endl << "Enter choice: ";
cin >> choice;
switch(choice)
{
case 0:
cout << "Exiting easy opener...\n";
//Sleep(1000);
return 0;
break;
case 1:
system("start winword");
break;
case 2:
system("pbrush");
break;
case 3:
system("calc");
break;
case 4:
char site[123];
char intern[] ="start iexplore "; /*103*/
cout << "Enter site: ";
cin >> site;
strcat(intern,site);
system(intern);
break;
default: /*line 110*/
cout << "Not a valid choice\n";
}//end switch
}//end while
}//end defining me operating system
if(strcmp(pszArgs[1],NULL)==0 )//opps! nothing found!
{
cout << "This program requries the use of Args\n"
<< "Use the name of your operating system\n"
<< "eg... -me for Millenium Edition\n\n";
cout << "Open a command prompt window and type pszArgs[0] -<short name
of system>";
cout << "Just don't use the << ";
system("pause");
return 1;
}
return 0;//exit program
}
_________________________________________________________________
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
|