|
From: Noorez K. <coo...@ho...> - 2004-05-29 07:10:54
|
This program needs args passed to it with the cmd prompt. If it doesn't find
any then it should display a message saying that you need the args but all I
get is an error message upon opening the program.
#include <iostream>
#include <cstdlib>
#include <string>
#include <conio.h>
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;
cin.sync();
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 ";
cout << "Enter site: ";
cin.getline(site,123);
strcat(intern,site);
system(intern);
break;
}
default://the choice wasn't a valid one if we are at default
cout << "Not a valid choice\n";
}//switch
}//end while
}//done defining nt operating system
else 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;
cin.sync();
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 ";
cout << "Enter site: ";
cin.getline(site,123);
strcat(intern,site);
system(intern);
break;
}
default:
cout << "Not a valid choice\n";
}//end switch
}//end while
}//end defining me operating system
else
{
cout << "Args needed\n";
system("pause");
return 0;
}
return 0;//exit program
}
_________________________________________________________________
Add photos to your e-mail with MSN Premium. Get 2 months FREE*
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
|
|
From: Noorez K. <coo...@ho...> - 2004-05-29 07:10:57
|
This program needs args passed to it with the cmd prompt. If it doesn't find
any then it should display a message saying that you need the args but all I
get is an error message upon opening the program.
#include <iostream>
#include <cstdlib>
#include <string>
#include <conio.h>
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;
cin.sync();
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 ";
cout << "Enter site: ";
cin.getline(site,123);
strcat(intern,site);
system(intern);
break;
}
default://the choice wasn't a valid one if we are at default
cout << "Not a valid choice\n";
}//switch
}//end while
}//done defining nt operating system
else 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;
cin.sync();
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 ";
cout << "Enter site: ";
cin.getline(site,123);
strcat(intern,site);
system(intern);
break;
}
default:
cout << "Not a valid choice\n";
}//end switch
}//end while
}//end defining me operating system
else
{
cout << "Args needed\n";
system("pause");
return 0;
}
return 0;//exit program
}
_________________________________________________________________
MSN Premium includes powerful parental controls and get 2 months FREE*
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
|
|
From: Per W. <pw...@ia...> - 2004-05-29 07:28:56
|
Of course you get. You are ignoring the first parameter, which specifies
number of parameters. If you don't give the program any arguments,
pszArgs[0] will be the name of your application, and pszArgs[1] will be
NULL. =C1 NULL pointer to strcmp isn't so nice!
By the way. How about cutting down a bit on your source code? I think the
source listing has been in this mailing list enough times now.
/Per W
On Sat, 29 May 2004, Noorez Kassam wrote:
> This program needs args passed to it with the cmd prompt. If it doesn't f=
ind
> any then it should display a message saying that you need the args but al=
l I
> get is an error message upon opening the program.
>
> #include <iostream>
> #include <cstdlib>
> #include <string>
> #include <conio.h>
> using namespace std;
>
> int main(int args, char* pszArgs[])//there needs to be args for this to w=
ork
> {
>
> if(strcmp(pszArgs[1],"-nt")=3D=3D 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 =3D 0;
> cout << "\nEnter the number of your choice: ";
> cin >> choice;
> cin.sync();
> 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[] =3D"start iexplore ";
> cout << "Enter site: ";
> cin.getline(site,123);
> strcat(intern,site);
> system(intern);
> break;
> }
>
> default://the choice wasn't a valid one if we are at default
> cout << "Not a valid choice\n";
> }//switch
>
> }//end while
> }//done defining nt operating system
>
> else if(strcmp(pszArgs[1],"-me")=3D=3D0)
> {
> 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;
> cin.sync();
> 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[] =3D"start iexplore ";
> cout << "Enter site: ";
> cin.getline(site,123);
> strcat(intern,site);
> system(intern);
> break;
> }
>
> default:
> cout << "Not a valid choice\n";
> }//end switch
>
> }//end while
>
> }//end defining me operating system
>
> else
> {
> cout << "Args needed\n";
> system("pause");
> return 0;
> }
>
> return 0;//exit program
> }
>
> _________________________________________________________________
> MSN Premium includes powerful parental controls and get 2 months FREE*
> http://join.msn.com/?pgmarket=3Den-ca&page=3Dbyoa/prem&xAPID=3D1994&DI=3D=
1034&SU=3Dhttp://hotmail.com/enca&HL=3DMarket_MSNIS_Taglines
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3D3149&alloc_id=3D8166&op=3Dclick
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|