Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan1-Aug-14 21:45
mveRichard MacCutchan1-Aug-14 21:45 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
mybm11-Aug-14 23:34
mybm11-Aug-14 23:34 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan2-Aug-14 0:41
mveRichard MacCutchan2-Aug-14 0:41 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
mybm12-Aug-14 2:06
mybm12-Aug-14 2:06 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan2-Aug-14 2:49
mveRichard MacCutchan2-Aug-14 2:49 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
CPallini2-Aug-14 2:59
mveCPallini2-Aug-14 2:59 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan2-Aug-14 3:05
mveRichard MacCutchan2-Aug-14 3:05 
AnswerRe: Put the other main in a namespace Pin
Software_Developer2-Aug-14 7:10
Software_Developer2-Aug-14 7:10 
In C++, you can only have one main.


The standard explicitly says in 3.6.1:

A program shall contain a global function called main,
hich is the designated start of the program.

[...] This function shall not be overloaded.


You can have two functions called main. The name is not special in any way and it's not reserved.
What's special is the function, and it happens to have that name. The function is global.
So if you write a main function in some other namespace, you will have a second main function.
C++
namespace secondMain
{
  int main() { return 0; } 
}

int main() 
{ 
   secondMain::main(); 

}

The first main function is not special - notice how you have to return explicitly.
GeneralRe: Put the other main in a namespace Pin
CPallini3-Aug-14 0:20
mveCPallini3-Aug-14 0:20 
QuestionC++ ofstream System.AccessViolation Pin
Kit Fisto1-Aug-14 5:07
Kit Fisto1-Aug-14 5:07 
QuestionRe: C++ ofstream System.AccessViolation Pin
CPallini1-Aug-14 6:11
mveCPallini1-Aug-14 6:11 
AnswerRe: C++ ofstream System.AccessViolation Pin
Kit Fisto1-Aug-14 6:22
Kit Fisto1-Aug-14 6:22 
GeneralRe: C++ ofstream System.AccessViolation Pin
CPallini1-Aug-14 22:05
mveCPallini1-Aug-14 22:05 
AnswerRe: C++ ofstream System.AccessViolation Pin
Kit Fisto4-Aug-14 23:49
Kit Fisto4-Aug-14 23:49 
AnswerRe: C++ ofstream System.AccessViolation Pin
Member 138550171-Jun-18 13:43
Member 138550171-Jun-18 13:43 
QuestionHow can I display Japanese characters in an application ? Pin
Swap930-Jul-14 23:12
Swap930-Jul-14 23:12 
QuestionRe: How can I display Japanese characters in an application ? Pin
Richard MacCutchan30-Jul-14 23:42
mveRichard MacCutchan30-Jul-14 23:42 
AnswerRe: How can I display Japanese characters in an application ? Pin
Swap930-Jul-14 23:53
Swap930-Jul-14 23:53 
QuestionImport CSV to Access DB. Pin
Member 1093049930-Jul-14 8:25
Member 1093049930-Jul-14 8:25 
AnswerRe: Import CSV to Access DB. Pin
Richard MacCutchan30-Jul-14 20:31
mveRichard MacCutchan30-Jul-14 20:31 
QuestionHow to consume web service in C++ using REST SDK.? Pin
mbatra3130-Jul-14 4:34
mbatra3130-Jul-14 4:34 
AnswerRe: How to consume web service in C++ using REST SDK.? Pin
Richard MacCutchan30-Jul-14 5:01
mveRichard MacCutchan30-Jul-14 5:01 
Questiontreeview ctrl rmb menu question Pin
bobfresh30-Jul-14 0:09
bobfresh30-Jul-14 0:09 
QuestionRe: treeview ctrl rmb menu question Pin
Richard MacCutchan30-Jul-14 0:37
mveRichard MacCutchan30-Jul-14 0:37 
Questioncan anyone help how to find summation of float number? Pin
mybm129-Jul-14 20:33
mybm129-Jul-14 20:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.