Boolshit.

Questions about programming languages and debugging
Post Reply
User avatar
Swan
Knight of the Sword
Knight of the Sword
Posts: 827
Joined: 18 Oct 2006, 16:00
17
Contact:

Boolshit.

Post by Swan »

Code: Select all

int main(int argc, char *argv[]) 
{
    return 0;
}
The above is a piece of code (which i dont understand lol)

also inserting

Code: Select all

 int main () 
and

Code: Select all

return 0;
also removes the errors.


Without the above coding the error messages are as follows:

[Linker error] undefined reference to `WinMain@16'
and

ld returned 1 exit status

I googled the problem, and entered the above code as specified. :S

As I said, theprogram does not seem to do anything.

p99
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 291
Joined: 14 Oct 2006, 16:00
17
Location: Some hippy's van
Contact:

Post by p99 »

int main(){
return 0;
}

All you need.
What are you using to compile it? And C or C++?

ebrizzlez
Kage
Kage
Posts: 732
Joined: 31 Mar 2007, 16:00
17
Location: Hidden in a Buffer Protection.
Contact:

Re: Boolshit.

Post by ebrizzlez »

baron_samedi wrote:

Code: Select all

int main(int argc, char *argv[]) 
{
    return 0;
}
The above is a piece of code (which i dont understand lol)

also inserting

Code: Select all

 int main () 
and

Code: Select all

return 0;
also removes the errors.


Without the above coding the error messages are as follows:

[Linker error] undefined reference to `WinMain@16'
and

ld returned 1 exit status

I googled the problem, and entered the above code as specified. :S

As I said, theprogram does not seem to do anything.
Well lets start,

your trying to pass unused parameters through the main() function so that wont work. You only use

Code: Select all

int main(int argc, char *argv[]) 
When you really need to use int argc, and the pointer argv[] that may pass as an Array. You can remove this part till needed.

Its good coding pratice to start like this:

Code: Select all

#include <iostream>
int main(){
return 0;
}
Then just add the varibles and the rest of the code as you start programming, if you have a never-ending loop then you may want to take out return because it would try to return VOID/NULL and exit the program.

Lets start, the int signifys a interget should be returning the main function main() . Now the the opening braces and closing indentify the start and beginning of the function. :wink:
[img]http://i81.photobucket.com/albums/j205/ebrizzlez/4lsint1.jpg[/img]

User avatar
Swan
Knight of the Sword
Knight of the Sword
Posts: 827
Joined: 18 Oct 2006, 16:00
17
Contact:

Post by Swan »

p99


i am using Dev-C++ 4.9.9.2. to compile the code, and it is C++ that i am coding in.

User avatar
Stavros
ΜΟΛΩΝ ΛΑΒΕ
ΜΟΛΩΝ ΛΑΒΕ
Posts: 1098
Joined: 02 Jan 2006, 17:00
18
Location: Mississippi, U.S.A.

Post by Stavros »

Well, the reason it doesn't do anything is because all that code says is to start the program and close successfully. In short: the program doesn't do anything useful.

Basically, all that little snippet of code is the standart template for coding in C++.

<b>#include <iostream></b>
-This is the header that allows input and output to occur in the program.

<b>int main()</b> or <b>int main(int argc, char *argv[])</b>
-This is exactly what is says; This is the main function of the program. This is where the majority of the programming will happen until you learn about functions (we'll discuss that as you get to it).

<b>return 0;</b>
-This tells the program to finish successfully (and if you're programming in Dev-C++ it will close the command prompt unless you put "system("pause");" ; "system("pause");" will allow you to view the results of your program).

On a side note; in Microsof Visual Studios you won't need "system("pause");", it automatically adds it.

Post Reply