Archived

This topic is now archived and is closed to further replies.

Sinner_Zero

Screwy error

Recommended Posts

I''m getting a wierd error here when compiling some code that should work, I got it from a tutorial and am testing my compiler, I''m using MVC++ 5. LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main that''s the error, this just uses some Windows GDI stuff, I have no clue where this error could be coming from. Anyone got any ideas?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You set your project to a console application when you should''ve
chosen Win32 Application.

Share this post


Link to post
Share on other sites
Cool, works like a charm.

Can anyone explain rand() and srand() to me quickly, more to the extent of what srand() does, I''ve never used the random number generator yet, would be really helpful please =)

Share this post


Link to post
Share on other sites
rand() calculates a pseudo-random number from the current seed value. srand() sets the seed value. If you for example srand(5) and then call rand() a few times, and then call srand(5) again and call rand() a few times again, then the first and second sequence of ''random'' numbers will always be the same because they are based on the same seed. A common practise is therefore to call srand with the current system time or some other value that won''t (likely) be the same each time you run the program (assuming you don''t want the number sequence to be the same each time).

IIRC there should be an option to install the C runtime source code when you install MSVC++. Look at the source for rand() to see the algorithm used.

There are usually better ways than rand() to get random numbers though (depending on how rand() is implemented). The Mersenne Twister should be pretty good.

Share this post


Link to post
Share on other sites
Cool, I knew there was no such thing as a real random number generator.....or did I.

Actually, thnx a lot there.

But is there any real random number generator, and I don''t mean for C/C++, I mean is there one in existance somewhere.

And this MT thing seems nice. I think I might be using it.

Share this post


Link to post
Share on other sites