NOT ENOUGH MEMORY C++ program is too large, URGENT (NEED HELP) :(

-
Last edited on
Are you building this all in one massive function, or one massive file, or something?

If you break your code up into sensible classes in separate files, then the compiler only has to compile one bit at a time.

If this is happening at link-time, then you probably want to break it into DLL's, rather than linking everything into one monolithic executable.
-
Last edited on
-
Last edited on
You can set aside memory, it's called allocating memory. But that has nothing to do with the problem you're experiencing.

I think you already realised this is an opprotunity to learb something about program structure and possibly data structure.
closed account (S6k9GNh0)
I'm just saying... how is your program 1.2 million lines of code for such a problem?
If you want to give us access to your code (unless you don't want to, in which case I understand), we could perhaps offer you some advice. Obviously don't attempt to post it into this forum, you need to put it on an accessable server.
For what limited value it's worth, my current project involves dealing out 52 cards for a bridge simulation. I'm able to specify specific hands and do various basic restrictions as well as collect a few statistics, and the code is about 0.1% as long (1262 lines), I doubt you need to use about 960 times the amount to calculate a winner though I suppose you are going to be dealing with huge amounts of hands- for a 22 handed game, it's 8C5 x 42C2 x 40C2 ....... x 2C2 for each specific hand, that is more about runtime than data though.
So... to answer your question I am a beginner at c++ (programming for about 6 months). I am self taught as well.

Everything is in one massive file ( I know, don't critisize). I have not learned about classes and object orientated programming yet.

I find it hard to fathom how you can have been learning C++ (or even C) for 6 months and not yet learned about functions. They should have been something you came across very early in the learning process.

Edit: Classes, and OO, are a bit more advanced, but not even learning about functions...

I'm just saying... how is your program 1.2 million lines of code for such a problem?

If he's not using functions then it's believable. There must be an eye-watering amount of repeated code in there!
Last edited on
-.
Last edited on
---> MikeyBoy Could you possibly send me the source code for the card game.

That was manudude03, not me, who's written a bridge program.
-
Last edited on
Copy and paste really works

Copy and paste is God's way of telling you that something's wrong with your program. The moment you find yourself copying and pasting chunks of code, that's a sure sign that you need to think about your design a bit more.

And I'm still staggered that, in 6 months of learning C++, you never encountered functions. What the hell were you using to teach yourself? A book with all but the first chapter torn out?
-
Last edited on
Bare in mind that even my code isn't exactly efficient (I have a lot of copy+pasted stuff myself), plus the TwoHand and OneHand functions aren't working right, been spending the last day or so fixing a bug with using a specific hand. Still, I have the source code saved on google docs (a "mere" 64 pages)

https://docs.google.com/document/d/12l_wdTzJ7uhwUN4yc3dcayezZtYEQT3VjWL9MSAbBV0/edit?usp=sharing
Last edited on
so why you dont use for loops?
if you use for loops, it doesnt give this error!
-
Last edited on
closed account (1yR4jE8b)
1.2 million lines of code


I have not learned about classes and object orientated programming yet.


been programming for 6 months




wat
What's with all the deleted posts? It at least gave the rest of the responses some context. Thinking about the texas holdem problem, as long as you only care about whether or not a hand is winning, you could probably have a 2D array, first element being the id of the "competitor" (number 0 being the hand you're ultimately testing), as an array also containing the hand type as an enum, plus 1st/2nd "kickers", I put "kickers" in inverted quotes as in the case of a full house of something, the 3rd element would be the three of a kind, and the 4th being the pair or something. It's likely a big runtime though.
What's with all the deleted posts?

Yeah - why would you do that? Now this thread will make no sense to anyone who tries to read it.
Topic archived. No new replies allowed.