GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Nov-2006, 11:12
Gamer_2k4's Avatar
Gamer_2k4 Gamer_2k4 is offline
Member
 
Join Date: Apr 2005
Location: Wisconsin
Posts: 117
Gamer_2k4 will become famous soon enough

Quick Looping Question


Would
CPP / C++ / C Code:
for (int i = 0; i < 20000; i++)
take less time to run than
CPP / C++ / C Code:
for (int i = 0; i < 100; i++)
     for (int j = 0; j < 200; j++)
?

I don't think it would, but I just added saving and loading into a game I'm writing, and a major hangup is saving the 100x200 maps. Is there a way to speed up this process, maybe some way to compress the data first?

Gamer_2k4
  #2  
Old 06-Nov-2006, 12:29
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,281
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Quick Looping Question


I don't think how you do the loops is your real question. It's how to save the maps effectively.

How do you declare the map? Structure? Matrix? You might want to consider outputting the entire map in one output command.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #3  
Old 06-Nov-2006, 13:11
Gamer_2k4's Avatar
Gamer_2k4 Gamer_2k4 is offline
Member
 
Join Date: Apr 2005
Location: Wisconsin
Posts: 117
Gamer_2k4 will become famous soon enough

Re: Quick Looping Question


That's a good idea. My map is a 100x200 array, but I can write a program to generate the cout statement. That might be the best way. Thanks.
__________________
Gamer_2k4
  #4  
Old 06-Nov-2006, 14:24
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,281
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Quick Looping Question


You don't use cout to save the map. That's for displaying the map. You need file I/O
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #5  
Old 06-Nov-2006, 17:23
Gamer_2k4's Avatar
Gamer_2k4 Gamer_2k4 is offline
Member
 
Join Date: Apr 2005
Location: Wisconsin
Posts: 117
Gamer_2k4 will become famous soon enough

Re: Quick Looping Question


Right, that was a mistake on my part. "cout <<" and "saveFile <<" are similar statements, since the syntax is the same. I merely mixed up the two in my response.
__________________
Gamer_2k4
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
win32 api message box quick question Tomb332 C++ Forum 3 11-Aug-2006 17:10
real quick crash question kangol848 Computer Software Forum - Windows 1 02-Aug-2006 01:53
a quick question ap6118 C++ Forum 5 30-Jan-2006 22:54
Merge and Heap...which is really faster silicon C++ Forum 0 10-May-2005 14:46
non-member function question crq C++ Forum 1 03-Feb-2005 22:59

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:24.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.