Author |
Message |
romantic_programmer

|
Posted: Thu Dec 18, 2008 10:26 pm Post subject: void main() error |
|
|
I am tring to complie my work here and i keep receiving these messages.
line file message
4 C:\Users\Jeremy\Desktop\Azuregale\Main.cpp `main' must return `int'
C:\Users\Jeremy\Desktop\Azuregale\Makefile.win [Build Error] [Main.o] Error 1
Example code below. i am running Dev C++ and within my Library.h is my #include <iostream> and my using namespace std;
Please can someone explain to me what i am doing wrong.
code: |
#include "Library.h"
void main()
{
// Welcome Screen
cout << "\n\nWelcome to AzureGale V0.0.01,\n";
cout << "Programmed By: Jeremy Poisson\n\n";
}
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: Thu Dec 18, 2008 11:21 pm Post subject: Re: void main() error |
|
|
romantic_programmer @ Thu Dec 18, 2008 10:26 pm wrote: `main' must return `int'
void is not int
code: |
int main(){
return 0;
}
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
romantic_programmer

|
Posted: Thu Dec 18, 2008 11:48 pm Post subject: RE:void main() error |
|
|
Thank you for the advice tony, but unfortunetly every time i try to run the program it shows nothing... shouldn't it at least show the text up in my example? |
|
|
|
|
 |
wtd
|
|
|
|
 |
romantic_programmer

|
Posted: Thu Dec 18, 2008 11:58 pm Post subject: RE:void main() error |
|
|
but i even ran it through a command shell.. shouldn't that at least stay open? well as i was reading it should but it dosn't even load anything |
|
|
|
|
 |
wtd
|
Posted: Fri Dec 19, 2008 12:15 am Post subject: RE:void main() error |
|
|
Post your code. Your latest code. Tell us exactly how you're trying to run it. |
|
|
|
|
 |
romantic_programmer

|
Posted: Fri Dec 19, 2008 12:22 am Post subject: Re: void main() error |
|
|
This is my latest code. Very simple but still
THis is the Main.cpp
code: | #include "Library.h"
int main()
{
// Welcome Screen
cout << "\n\nWelcome to AzureGale V0.0.01,\n";
cout << "Programmed By: Jeremy Poisson\n\n";
cout << "A land that has been divided up into Kingdoms and\n is at risk of falling into a Kingdoms War. Though their has been violence\n with in the lands it seems to have gotten even more chaotic in \nrecent years. You believe you are the world last hope for global peace. \nIf not may the Gods save all who are worthy of their grace.";
return 0;
}
|
This is the Library.h
code: |
#include <iostream>
using namespace std;
|
I haven't added anymore since i couldn't get it to run. |
|
|
|
|
 |
wtd
|
Posted: Fri Dec 19, 2008 12:49 am Post subject: RE:void main() error |
|
|
Works fine here. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
romantic_programmer

|
Posted: Fri Dec 19, 2008 12:58 am Post subject: RE:void main() error |
|
|
i am so confused. do you think it could just be the default DEV C++ 4.9.9.2 compiler? |
|
|
|
|
 |
DemonWasp
|
Posted: Fri Dec 19, 2008 1:03 am Post subject: RE:void main() error |
|
|
That should all work fine. It's worth noting that you should use "endl" instead of "\n":
cout << "Programmed By: Jeremy Poisson" << endl << endl;
If you still are having trouble, list the exact series of commands you're using to compile and run your program. |
|
|
|
|
 |
romantic_programmer

|
Posted: Fri Dec 19, 2008 1:11 am Post subject: Re: void main() error |
|
|
code: | #include "Library.h"
int main()
{
// Welcome Screen
cout << "\n\nWelcome to AzureGale V0.0.01,\n";
cout << "Programmed By: Jeremy Poisson" << endl << endl;
cout << "A land that has been divided up into Kingdoms and\n is at risk of falling into a Kingdoms War. Though their has been violence\n with in the lands it seems to have gotten even more chaotic in \nrecent years. You believe you are the world last hope for global peace. \nIf not may the Gods save all who are worthy of their grace.";
AzurianGates();
return 0;
}
|
it still didn't work. I am starting to think it is the compiler or something because when i load the application even in the command prompt it shows nothing. just goes to the next line.
also i have a question about syntax what is proper \n or endl; |
|
|
|
|
 |
wtd
|
Posted: Fri Dec 19, 2008 2:18 am Post subject: RE:void main() error |
|
|
use endl. |
|
|
|
|
 |
romantic_programmer

|
Posted: Fri Dec 19, 2008 2:27 am Post subject: RE:void main() error |
|
|
And can you possible suggest a a better compiler... i am running vista home basic. if that helps |
|
|
|
|
 |
wtd
|
Posted: Fri Dec 19, 2008 3:02 am Post subject: RE:void main() error |
|
|
Which compiler (and version) are you using now? |
|
|
|
|
 |
romantic_programmer

|
Posted: Fri Dec 19, 2008 3:07 am Post subject: RE:void main() error |
|
|
Well I just Downloaded Dev - C++ 4.9.9.2
and i am using it's default compiler which i think is the mingw. |
|
|
|
|
 |
|