Passing command line arguements -Whats wrong with this code and can anyone help me out

Whats wrong with this code and can anyone help me out

Created a win32 console application and passed a command line
arguements like
C:\CMDLINE\DEBU\cmdline.exe one

Now my program should print ---one

So in the program this is the code I wrote but IT FAILED.The screen
disappears in a flash.Pls help .Thanks in advance

---------------PROGRAM----------------------------------------
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;
cout <<" in  main ";
	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else if(argc>1)
	{
		// TODO: code your application's behavior here.
		cout << (LPCTSTR)argv[0] << endl;
		
	}

	return nRetCode;
}

0
nicetom786 (68)
3/16/2006 11:31:50 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
388 Views

Similar Articles

[PageSpeed] 15

<nicetom786@yahoo.com> wrote in message 
news:1142551910.053783.195580@i39g2000cwa.googlegroups.com...
| Whats wrong with this code and can anyone help me out
|
| Created a win32 console application and passed a command line
| arguements like
| C:\CMDLINE\DEBU\cmdline.exe one
|
| Now my program should print ---one
|
| So in the program this is the code I wrote but IT FAILED.The screen
| disappears in a flash.Pls help .Thanks in advance
|
| ---------------PROGRAM----------------------------------------
| int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
| {
| int nRetCode = 0;
| cout <<" in  main ";
| // initialize MFC and print and error on failure
| if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
| {
| // TODO: change error code to suit your needs
| cerr << _T("Fatal Error: MFC initialization failed") << endl;
| nRetCode = 1;
| }
| else if(argc>1)
| {
| // TODO: code your application's behavior here.
| cout << (LPCTSTR)argv[0] << endl;
|
| }
|
| return nRetCode;
| }

argv[0] is the pathfilename of your application.  The arg you're looking for 
is at argv[1].
If you want the app to give you time to see the screen you'll have to wait 
for a key:
E.G.,
    cout << "Press any key...";
    getch();

- Ed. 

0
Anon3258 (180)
3/16/2006 11:48:04 PM
Reply:

Similar Artilces:

format text to follow line
In Publisher 2003, can text be set to follow a curved line. I want to enter text to follow a tight corner around an image. I have tried wordart, but I don't want both ends to close in to form a circle, but to be vertical down one side, bend tightly and then horizontal along top of image. Like a circle of text - but the ends straightened out to be at 90degrees to each other. Publisher hasn't the drawing tools to do what you are trying to accomplish. Maybe using two or three WordArt Objects? -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews...

change two lines of text data to one
when i extract data from a data base in text form, each record is on two lines. Every record is comprised of a number of fields separated by spaces. How do i spread each record onto a single line so that I can work with each individual field in access. Instead of exporting a text file, and opening it in Excel, maybe you can import directly from the other database to Access. the turtle wrote: > when i extract data from a data base in text form, each record is on two > lines. Every record is comprised of a number of fields separated by spaces. > How do i spread each record onto ...

help (sorry if double posted)
Need a way so in Cell A1 it shows the last date the file was updated and saved. Right now it shows the current date which is not working for this file... Thanks to all. Did you double-post out of impatience....it has been a whole 25 minutes<g> or because you can't see your first post? Whatever, I replied to your first post. Gord Dibben MS Excel MVP On Sat, 24 Oct 2009 09:55:17 -0700, "Bob Bob" <NoMail@yahoo.com> wrote: >Need a way so in Cell A1 it shows the last date the file was updated and >saved. Right now it shows the current date which is not work...

Error with on-line payment (Money 2002)
My computer locked up in the middle of sending an e- payment. My bank got the payment but Money shows to transaction is still pending. Because of this, Money doesn't show the payment in the resgister and it won't let me delete or edit the payment since it still shows it as pending. Can anybody tell me how to delete this transaction???? THANKS!!! Don ...

Help with excel formula... Please
I want to take the LAST cell of column A (which will be changing with entries) and paste it into a fixed cell in column B. Thanks The formula: =OFFSET(A1,COUNT(A2:A1000),0) in any cell will result in the value of the last occupied cell in Column A. Note that cell A2 must be occupied. HTH Otto "ventimaj" <ventimaj@discussions.microsoft.com> wrote in message news:FDCA035C-E8F4-4ECF-9CB5-E2FBE88A89AA@microsoft.com... >I want to take the LAST cell of column A (which will be changing with > entries) and paste it into a fixed cell in column B. > > Thanks Otto...

How do I use line numbering but not have it show on print?
I do not want the line numbers to show in printed material. Meinert wrote: > I do not want the line numbers to show in printed material. Go into the Page Setup dialog and turn off line numbering before you print. If you want it, turn the numbering on again afterward. To automate this, install the following macros in your Normal template (see http://www.gmayor.com/installing_macro.htm if needed): Sub FilePrint() ' intercepts built-in File > Print or Ctrl+P ' and prints without line numbering Dim userLineNum As Boolean With ActiveDocument.PageS...

need help from Excel Pro....
I have a spreadsheet with 2 worksheets. 1 worksheet has a list of numerical codes with data in two other columns that are associated with each code. I want to be able to enter any one of those numerical codes into the second worksheet and have it automatically pull in the associated data to those codes. Can someone tell me how or point me in the right direction for information to accomplish this. Huge Thanks!!! Dan Brimley wrote: > I have a spreadsheet with 2 worksheets. 1 worksheet has a list of > numerical codes with data in two other columns that are associated > with each ...

2 part question
first of all I seem to be having a little difficutly in recording a macro to just open a form to input database information on the row under the labels of each column. I know I can just open form after highlighting the row of labels and put the information in that way. But I want a button on the spreadsheet to click onto to open the form to input the data, and a button to do a search in the same fashion. My first problem is getting the macro to record properly. Second will be to get the command button to run the macro. I think I can do the second part of this but need the macro to do it...

Zip code sort is an Excel problem even when using the special cat.
Zip code sorting is a problem using excel 2003. I have zips both in 4 and 9 digit format. I have tried every conceivable format and even followed the recommendation online by typing in the custom category [<=99999]00000;00000-0000. I have tried to retype in the zip codes but that doesnt seem to help. Note that some info comes in from older excel versions and from Word docs. Can anyone help? I only use 4 digit zip coding, but it has always worked very well when sorting. I use a Custom format of 0000, so that 0001 will show like that. "camead" wrote: > Zip code sorting i...

i need help with the trim line
HI i would like to know how do i insert the trim line into my business card template? i save my design as a jpeg and upload it to vistaprint.com but it always get cut i dont know how to insert the trim line or full bleed? whats the difference between both? thanks -- judy judy wrote: > HI > i would like to know how do i insert the trim line into my business > card template? > i save my design as a jpeg and upload it to vistaprint.com but it > always get cut i dont know how to insert the trim line or full bleed? > whats the difference between both? thanks =================...

Wrong matched transaction
I accidentally matched a downloaded transaction to the wrong registry entry (same amount but later date). Is is possible to unmatch and trigger an rematch? Bruce. Only way I have ever gotten this to work is delete the transaction and then redownload. The second download will have to be manual to get the item downloaded again. Art "Bruce Chastain" <bachastain@XNOSPAMXsbcglobal.net> wrote in message news:%23UA$F79HHHA.3676@TK2MSFTNGP03.phx.gbl... >I accidentally matched a downloaded transaction to the wrong registry entry >(same amount but later date). Is is ...

How can I change the display name
How do I change the named displayed as "from" on my email messages? I send updates about the band I play in to a group of people. I'd like these messages to show the name of the band as "from". but I'd also like to keep my name displayed in the "from" line on personal email messages. I know I can go to the account settings and change it but I was wondering if there is some automatic way of making this happen. Thanks, Don........... Don <vze2t273@verizon.net> wrote: > How do I change the named displayed as "from" on my email messag...

Can't convert Quicken qdata file.
I am try to switch from Quicken to Money 2004. When it trys converting the Quicken I get the following message: Your Quicken file could not be converted. You are attempting to convert a corrupted Quicken file. Try reindexing your Quicken file by clicking File Operations from the File menu, and then clicking Validate. Then try converting it again. Have tried validating the quicken file but no change. I don't want to lose all the data I have in Quicken. Any suggestions??? Thanks Sam In microsoft.public.money, Sam Roe wrote: >I am try to switch from Quicken to Money 2004. When it...

How can I retrieve a subfolder that has disappeared?
When I try to reorganize the folders from Outlook, I accidentally move a sub-folder from Inbox folder and lost the sub-folder. I am using Microsoft Office 2003, SP3. May I know how to retrieve that sub-folder? Thank you. show the Folder List in the Navigation Pane (folder button, bottom left corner of your screen). Find the folder and darg it back to where you want it. -- Regards Judy Gleeson MVP Outlook in Canberra, Australia "Hau" <Hau@discussions.microsoft.com> wrote in message news:19FE8881-B69E-4F33-AEB0-BD33211A6F84@microsoft.com... >...

Can't boot or access C drive
Windows XP won't boot. I tried reinstalling Windows but keep getting a blue screen even after deleting, recreating and formatting the C drive. I booted with an MSDOS floppy but can't access C drive. It may be a boot sector virus. How do I format the entire hard drive so I can do a clean install? "rj" <rjnothere@netzero.net> wrote in message news:ulZXW#DJLHA.1868@TK2MSFTNGP05.phx.gbl... > Windows XP won't boot. I tried reinstalling Windows but keep getting a > blue > screen even after deleting, recreating and formatting the C drive. I &g...

Is It Possible To Pass Parameters to A Pass Through Query
My assumption is that's it's not. At work I use ODBC to connect to our oracle database with Access 2003. There are cases where using a pass through query runs much much faster and I then use it in a make table query to make a local table. In access you can use brackets [] to have it ask for input. May I assume there is no way to do anything like that in a pass through query? Create a PassThrough query and use code to assign the SQL to this query filtering it with a parameter, and then run it e.g Dim MyVariable As Integer MyVariable = InputBox("Please select a Number&quo...

Can't Send and Recieve Email
Somehow I broke my Outlook 2003 email. When I click on "Send/Receive" or "Send/Recieve All" nothing happens. If I click on "Specific Account Only" I can receive that account's email in my In box but cannot send any email from that account out. Everything was working fine two days ago. Any advice is welcome. Thanks. Fred Kruger ...

Service Activity Relationship Customisation
I'm having the same problem as the one described here: >> I am having problems customizing a form in CRM 3.0 and would appreciate >> any assistance. >> >> When customizing the Service Activity Form ("The main application >> form") a field called "Regarding" exists under the Details >> section. It is possible to align accounts, contacts, cases etc in this >> field. I am trying to add a field that forces the users to align the >> Service Activities with an existing Case via a lookup and not give the >> user options ...

can you capture info from a cell without retyping in another cell
I'd like to be able to update the salutation in a letter with the person's name in the address without having to retype it. I am using Microsoft Office 2003. See http://gregmaxey.mvps.org/Repeating_Data.htm. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. jallen449 wrote: > I'd like to be able to update the salutation in a letter with the > person's name in the address without having to retype it. I am using > Microsoft Offi...

Remove edit from approval code box
Is there any way within RMS or via an addon that the approval code box could be grayed out to prevent cashier's entering an approval code? We do not do any phone authorizations, so we'd only need it to be able to get an approval code when RMS contacts the processor and retries its own approval code. Thanks! David, Use RMS Security to lock this out. To this follow these steps: 1. Log into POS 2. Click the blank function button in the lower left-hand of the screen. This should put a yellow lock in this box. 3. Begin a sale like you would, and tender to a credit ca...

can't customize toolbar
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel all i see is document elements, quick tables, charts and smartart graphics. i do not see the main menu or the toolbar button. when i attempt to customize the toolbar, the to menu bar and format bar do not appear where they should. on a website i visited, they advised that i drag and drop the temporary toolbar into the real toolbar. but i can't drag and drop the toolbar. i can only move the temporary toolbar. how do i add the menu bar and format bar for go? You may have hidden the toolbar by accident. Click on the ti...

Can not replace commas
I am trying to replace the commas in a big spreadsheet, so that I can save the spreadsheet as a csv file. But, I keep getting the error "formula too long." Some cells have a lot of informaion - not formulas. Anyway, what can I do? Insert a new worksheet, and in cell A1 enter =SUBSTITUTE(Sheet1!A1,",","") and copy to as many cells as you need to cover the entire sheet. HTH, Bernie MS Excel MVP "walterbyrd" <walterbyrd@iname.com> wrote in message news:f806b095-9e4a-4cea-bf36-b364e1543ec6@j9g2000prh.googlegroups.com... >I am trying to replac...

Command Button
I am unable to locate the section I need to add a commandbutton to excel worksheet. Where can I find this at? Thanks, Les EXCEL 2007 Type the word:- button - into the F1 Help Facility and hit Search. The first topic that is displayed is called:- Add a button or command button to a worksheet Go into the above topic. If my comments have helped please hit Yes. Thanks. ...

Money 2007: Help for former Quicken users
To start, two questions: 1) What do "Increase" and "Decrease" mean? I assumed that an increase would be a deposit and a decrease a withdrawal, but it doesn't look like that in the register. 2) In 2007 some of my purchases appeared with "Debit" as the check number, which is what I wanted but cannot duplicate. I use a debit card a lot, but want to show purchases in my check register. Now when I enter a purchase nothing at all appears in the check number field. I'm sure I saw--somewhere!--the option to select that. Where did I miss it? -- Natchitoch...

Can you use Crystal Standard to create reports in MS CRM?
If the Standard version of Crystal 9.2.2 doesn't allow for report creation, which version is required? Thanks for the help "astuartmills" <astuartmills@discussions.microsoft.com> wrote in message news:C6C33DEA-7BBC-4088-97E3-CFFDFF777622@microsoft.com... > If the Standard version of Crystal 9.2.2 doesn't allow for report > creation, > which version is required? Thanks for the help Either Crystal Developer or Crystal Professional Julian Hi Julian, Thank you for the follow up. "Julian Sharp" wrote: > > "astuartmills" &l...