Archived

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

A few simple C questions

This topic is 6361 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

A few Qs maybe I should know the answers to... Q1 How efficient is a really long case statement? I''m going to have a loop which runs lots of times and has lots of cases (with numbers in order, if that helps). Is it better just to put a few IFs around to cut it in 1/2s and 1/4s? Q2 Is there some command line option that stops at a certain number of errors (would be handy for my current setup). My compiler is djgpp. Q3 Is there some function which tells you how much memory you have left? This would be handy for checking if I''m making more objects than I''m deleting.

Share this post


Link to post
Share on other sites
1: it''s probably just as efficient as the equal numbe or if statements, just easier to type.
2: not that I know of for DJGPP, but you can with MSVC++.
3: the start->programs->applications->system tools->resource meter. read you resources before and after you run your program for memory leaks. for actually finding how much memory is used there a few prorams out there the will do that. I don''t remember any names but I do remember seeing them.

JoeMont001@aol.com www.polarisoft.n3.net

Share this post


Link to post
Share on other sites
If you''re using VC++, then you should check out _CrtDumpMemoryLeaks in the docs. Very useful functions for detecting leaks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Jump tables are faster than big switch statements. Some compilers will try and convert big switch statements into jump tables. You might build it and look at the disassembly and see what it''s doing.

Share this post


Link to post
Share on other sites
Sorry, I didn''t notice that you said your compiler was djgpp when I posted before I don''t know of any standard function to check for the amount of free memory.

Share this post


Link to post
Share on other sites