Sign in to follow this  
miomo

Dev-C++ help

Recommended Posts

miomo    100
So i recently started programming (C language), and by recently i mean VERY recently. I decided to download Dev-C++ after trying, and failing, to set-up many other C compilers. Well i got it, and i've been reading a book so i decided to copy down another program from it [ already did printf() ] to try it again. Well after finishing it and compiling it, i got the infamous "multiple definitions of 'main'" error.
Specifically:
multiple definitions of 'main'
first defined here
Id returned 1 exit status

And heres it is... I know it's cheesy...
****start program****



#include <stdio.h>
int main()
{
int age;
float weight;
char first[15], last [15];

printf("\nWhat is your first name? ");
scanf(" %s", first);
printf("What is your last name? ");
scanf(" %s", last);

printf("How old are you? ");
scanf(" %d", &age);
printf("How much do you weigh? ");
scanf(" %f", &weight);

printf("\nHere is your information:\n");
printf("Name: %s %s\n", first, last);
printf("Weight: %f\n", weight);
printf("Age: %d\n", age);

return 0;
}



****end program****

So... Yup... Any help would be appreciated.

Share this post


Link to post
Share on other sites
rip-off    10976
The linker says you have more than one copy of main in your program. An example might be if you have two different source files which have main() implementations. Or perhaps you have main() in a header file that is included into two source files.

Be aware that Dev-C++ is horrendously out of date, buggy and not maintained. Do yourself a favour and download Visual C++ 2010 Express instead, it is free and is probably the best C++ IDE available for Windows.

Share this post


Link to post
Share on other sites
beatlefan    198
[quote name='rip-off' timestamp='1310557241' post='4834785']
Do yourself a favour and download Visual C++ 2010 Express instead, it is free and is probably the best C++ IDE available for Windows.
[/quote]


Yes, I highly doing recommend this. If for some reason you don't want to, at least get Code Blocks.

Share this post


Link to post
Share on other sites
SuperVGA    1132
[quote name='beatlefan' timestamp='1310562163' post='4834810']
[quote name='rip-off' timestamp='1310557241' post='4834785']
Do yourself a favour and download Visual C++ 2010 Express instead, it is free and is probably the best C++ IDE available for Windows.
[/quote]

Yes, I highly doing recommend this. If for some reason you don't want to, at least get Code Blocks.
[/quote]

Agreed, -or if you find setting up the environment all confusing (so did I when I first started with C++),
just get [url="http://sourceforge.net/projects/mingw/files/"]MingW[/url] containing the gcc compilers for windows, and compile from cmd instead.
Of course, you'll be missing out on all the other great features of an IDE, but it will be just you and the concept of learning a language. ;-)

It's very simple: [url="http://www.cs.bu.edu/fac/gkollios/cs113/Usingg++.html"]http://www.cs.bu.edu...3/Usingg++.html[/url]

Share this post


Link to post
Share on other sites
Nypyren    12061
In Visual Studio, you first need to create a project. Go File -> New -> Project, find and choose Win32 Console Application, choose all of the defaults. It'll create a bunch of files for you, including a <projectname>.cpp. Open that one and write your code in there.

By default, it will also create a precompiled header (stdafx.h and cpp) for you. You can ignore it if you wish, but eventually if your project becomes large, you can put commnly used #includes inside the stdafx.h file which can drastically speed up compile times.

Once you have a project created, the Debug menu will have items like "start debugging" and other useful stuff.

You're free to customize your hotkeys in Tools -> Options -> Environment -> Keyboard.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this