C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 13th, 2004, 03:42 PM
Izkata Izkata is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 6 Izkata User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy C++, Arrays, Changing only parts.

OK, first off, a small introduction: I'm new here, and learning C++ at school - I'm 15 (almost 16) years old. And reading ahead in the book

Anyway, I have:

int Place[30][30];
for(int Count1 = 0;Count1 < 30;Count1++)
{
for(int Count2 = 0;Count2 < 30;Count2++)
{
Place[Count1][Count2] = 9;
}
}

So, a 30x30 array of ints filled with 9s. What I'm wondering is if there is a simple way of changing the first 12x12 into 1s and 0s.

Yes, this may seem like a strange question, but I am testing my limits by trying to make a *very* simple text-based game.

Reply With Quote
  #2  
Old February 14th, 2004, 09:22 PM
Izkata Izkata is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 6 Izkata User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
From another board: the quote on a reply, and my answer.

Quote:
Originally Posted by major_blagger
Code:
for (count1 = 0; count1 < 12; count1++)
  for (count2 = 0; count2 < 12; count2++)
    place[count1][count2] = (count1 + count2) % 2;


Hrm.... A checkerboard of 1s and 0s... Well... <looks back>

I shoulda explained a bit better...

Okay. Here's the scenario:

A 30x30 array of 9s.
a 12x12 array of 1s and 0s, different patterns an whole buncha stuff.

I want the 12x12 array to be inserted in the start of the 30x30 array. I was looking in my C++ book earlier today, and found a section on "Vectors", but since it only had an example, and not even all the source for the example, I couldn't figure it out. But it did say that "Vector" is a term for a 1 dimensional array....

Is there a 2 dimen. version? The one in the book could is the assignment operator to change the size of the receiving array and assign another array to equal it... Just what I'm looking for, except wrong # of dimensions....

Reply With Quote
  #3  
Old February 15th, 2004, 09:02 PM
Izkata Izkata is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 6 Izkata User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Neeeever mind, I can use nested loops to copy it element by element....

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > C++, Arrays, Changing only parts.


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap