View unanswered posts | View active topics It is currently Wed Oct 01, 2014 1:59 am






Reply to topic  [ 3 posts ] 
iterating through string arrays 
Author Message
Rookie

Joined: Fri Apr 20, 2007 3:22 am
Posts: 36
Post iterating through string arrays
Howdy,

I want to be able to iterate through a string array.

I would expect this to work.

string array[3] = {"apple","box","chair"};

for(cnt =0; $cnt<2; cnt++)
nxtDisplayTextLine(1,array[cnt]);

It only displays the first character of the element.

however

nxtDisplayTextLine(1,array[1]);

will display "box" to the LCD.

Is this a bug or am I doing something wrong here?


Sun Jun 24, 2007 5:19 pm
Profile
Rookie

Joined: Mon Feb 25, 2008 5:21 am
Posts: 2
Post 
I have the same problem too...


Mon Feb 25, 2008 6:12 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 604
Post 
Hi All,

I tried your sample program out. I made a few modifications to the code and it seems to be working. Let me know if this is your desired output:

Code:
task main()
{
   string array[3] = {"apple","box","chair"};

   for(int cnt = 0; cnt<3; cnt++)
   {
   nxtDisplayTextLine(1,array[cnt]);
   wait1Msec(1000);  //so we can actually see the text on the screen
   }
}

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Mon Feb 25, 2008 4:11 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.