Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how do run int main(int argc,char * argv[]) in the visual C++

Status
Not open for further replies.

hero0765

Member level 2
Joined
Sep 15, 2008
Messages
52
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
China
Activity points
1,605
hi:
I want to run the below code in the the visual C++

#include<iostream>
#include<cstdlib>
#include<iomanip>
using namespace std;

int main(int argc,char * argv[])
{

cout << "argc = " <<argc <<endl;
for(int i =1; i<argc ;i++)
cout << "argv[" << i <<"] = "
<< argv << endl;

}

but the compiler run error:
: fatal error C1071: unexpected end of file found in comment

My project was built in the Win32 Console Application.

how can I disolve it ?
 

are you sure you posted the faulty code? I copied it into Visuall C++ and it compiles and runs OK.
 

Hi,

Make sure to set your compiler to not use a precompiled header, or if you do, provide one (such as stdafx.h).
(If you use VC++6, do Project->Settings->C/C++ tab->select "Precompiled Headers" in the "Category" dropbox and select "Not using precompiled headers" radio button.)

Arthur
 

the compiler still can not be compiled without errors. I am using VC++ 6.0, any settings need to be made? I have made the settings provided by "arthur0" ,but the compiler have another error:
: fatal error C1071: unexpected end of file found in comment

how can I do?
 

As horace1 pointed, I've also been able to compile your code without problems.

Are you sure you've given us the complete code? It sounds like you have a comment (i.e. "// some comment") on the last line of your file without a new line at the end...
If that's the case, make sure you go to the very end of the source file and press "Enter" to have an empty line at the end.

Just to be sure you have the right settings, copy the settings below and paste them (overwrite existing settings) in your Project->Settings->C/C++ tab->"Project Options" edit box.
Code:
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
 

hi:
thanks arthur0's help.
I have did as the same as you said, but the compiler still has errors :

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/CommandLineArgs.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

CommandLineArgs.exe - 2 error(s), 0 warning(s)

what's wrong with my compiler?

---------- Post added at 04:03 ---------- Previous post was at 03:55 ----------


my project settings is as the same as the picture showed.
 

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

WinMain is the entry point in a Windows application. I thought you said you wanted a console application, but that’s obviously not what you’ve created (you chose the wrong wizard).

Anyway, the code you posted can only run as a console, so change the linker’s settings (in the ”Link” tab) to specify ”/subsystem:console” (instead of existing ”/subsystem:windows”).

Even better, copy the settings below and overwrite your linker’s (“Link” tab) project options:
Code:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/CommandLineArgs.pdb" /debug /machine:I386 /out:"Debug/CommandLineArgs.exe" /pdbtype:sept
Arthur
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top