Jump to content
  • Advertisement
Sign in to follow this  
1stMan

Running a program

This topic is 4875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm a real beginner and I'm sorry for the level of question this is, but I have a problem running some code. I copied the code from a website that said this: "...we have included a small program written in "C". If you have a C compiler, try it out. It is a complete working program." I've tried running the code and just can't get it to work? Can somebody please help? I've put the code below. Thanks. #include "stdio.h" #define MaxIters 200 #define SIZE 80 #define BLACK -1 #define LEFT -2.0 #define RIGHT 1.0 #define TOP 1.0 #define BOTTOM -1.0 main(int argc, char *argv[]) { short x, y, count; long double zr, zi, cr, ci; long double rsquared, isquared; for (y = 0; y < SIZE; y++) { for (x = 0; x < SIZE; x++) { zr = 0.0; zi = 0.0; cr = LEFT + x * (RIGHT - LEFT) / SIZE; ci = TOP + y * (BOTTOM - TOP) / SIZE; rsquared = zr * zr; isquared = zi * zi; for (count = 0; rsquared + isquared <= 4.0 && count < MaxIters; count++) { zi = zr * zi * 2; zi += ci; zr = rsquared - isquared; zr += cr; rsquared = zr * zr; isquared = zi * zi; } if (rsquared + isquared <= 4.0) printf("*"); else printf(" "); } printf("\n"); } return 0; }

Share this post


Link to post
Share on other sites
Advertisement
What compiler are you using? The message almost looks likie it says it wrote it to your C drive and now you need a C compiler to finish it. Knowing the compiler your using would be great. [grin]

Share this post


Link to post
Share on other sites
I can't really see anything wrong with the syntax. Can you give us the errors your getting? Or does the program just crash?

--Ter'Lenth

Share this post


Link to post
Share on other sites
I'm running it in Visual Studio.

The errors are:

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

&

Debug/fractal2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Share this post


Link to post
Share on other sites
Yeah that is what I've done. I had no idea which one to choose so I just guessed. I'll try the console based one.

Thanks a lot for the help.

Share this post


Link to post
Share on other sites
Looks like you're trying to compile a Win32 app, when what you've written is a console application.

The compiler is looking for an entry into a WinMain function that doesn't exist.
Try starting a "new" project and specifying that it will be of a Win32 console type (not Win32) to avoid that linking error.

Share this post


Link to post
Share on other sites
I think you've created a Windows application, when you meant to create a console application. If you're using Visual Studio, try creating a new project, then for the project type, use 'Win32 Console Application'. Then you'll be set. BTW: You may want to have a return type for the main function (see below).

int main(int argc, char *argv[]) {

...

return 0;
}

Hope that helps.

-Otakuidoru

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!