The main function is the entry point of your application. The minimal main() function is as follows:
int main()
{
return( 0 );
}
Clearly this does nothing but return the value zero to the caller. However, it is important to note that the main() function must return an integer to the calling program -- even if only zero. The return value may be used to indicate an error condition, with zero indicating success, but can be used for any purpose -- or it may be ignored altogether by the caller. However it is not for you to decide how the return value is used, so long as you return something. A main() function that returns void is an invalid program (some compilers may permit it, but they break the C/C++ standard if they do).
An actual main() function will normally include one or more sequential statements or function calls, or an infinite loop with a conditional expression to exit the loop. An infinite loop may be contained in another function. The loop may be used to process a message queue, for instance, which determines the program's flow of control.
The following example demonstrates a simple program containing infinite loop within main() itself, generating random numbers between 1 and 100 (inclusive), exiting the loop when the number is 1. The return value is the number of loops that were executed.
#include
#include
int main()
{
srand(( unsigned ) time( NULL ));
unsigned int loops = 0;
while( ++loops )
{
int n = rand() % 100 + 1;
std::cout << "Number: " << n << std::endl;
if( n == 1 ) break; // exit loop if n is 1.
}
std::cout << "Loops: " << loops << std::endl;
return( loops ); // return number of loops to caller.
}
int main (void) { puts ("charminar"); return 0; }
what is the pure algorithm instead of cpp program?
I believe it was in 1967
It depends on linker. Microsoft's linker has option /ENTRY which allows to set name of an entry point function. c:\>type 1.cppincludeint my_main(int argc, char* argv[]) { printf("my_main\n"); return 0; }c:\>cl 1.cpp /MD /link /SUBSYSTEM:CONSOLE /ENTRY:my_main Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved.1.cpp Microsoft (R) Incremental Linker Version 8.00.50727.42 Copyright (C) Microsoft Corporation. All rights reserved./out:1.exe /SUBSYSTEM:CONSOLE /ENTRY:my_main 1.objc:\>1 my_mainc:\>With any text-editor, but be warned: if you don't have a function by name main, your program won't build (right, if in Windows, then it is WinMain).
The .cpp extension is merely conventional; it is not required by the C++ standard. You can actually use any file extension you wish.
Go to the link. You will got use of "this" keywork with simple explanation and example. http://cpp.codenewbie.com/articles/cpp/1527/Keyword_this-Page_5.html
CPP
int main (void) { puts ("charminar"); return 0; }
CPP Group was created in 1980.
#include <windows.h> int main() { system("cls"); return 0; }
There is no difference between the C main function and the C++ main function.They are both defined as int main (int argc, char *argv[]) {statements}.There have been different syntaxes over the years, but the end result is the same. There are also some variations, such as adding a char *envp[] argument to pass the environment, but that is not standard usage. It is also possible to have no arguments, as in int main() {statements}.
// 2 dimensional array (a sudoku puzzle): char sudoku[9][9]; // 3 dimensional array (100 sudoku puzzles): char sudokus[100][9][9]
The population of CPP Studios Event GmbH is 30.
CPP Studios Event GmbH was created in 1983.
In order to use extern you have to have at least two files. In first one, let's call it file1.cpp, you will define a variable using extern (in this case belongs to int):...extern int myVar = 0;...Then in file2.cpp file where you have main() you need to write following:extern int myVar;Do not initialize the variable in file2.cpp, or you code will not compile.
what is the pure algorithm instead of cpp program?
I believe it was in 1967