Author Topic: Printing out values of an array  (Read 1666 times)

bous006

  • Guest
Printing out values of an array
« on: January 10, 2013, 05:56:08 pm »
Im very new(started yesterday) and i was wondering if anyone could tell me how i would print a specific value of an array for instance my code now is.

              string soot[3] = {"bla", "bleh", "poo"};

      for(i = 0; i < 3; i++)
         TextAdd(60,120,soot,fh2);

any help would be nice, thanks

DeadSn0wMan

  • Guest
Re: Printing out values of an array
« Reply #1 on: January 11, 2013, 05:50:39 am »
TextAdd(60,120,soot[2],fh2) <--- this would print "poo"
TextAdd(60,120,soot[1],fh2) <--- this would print "bleh"
TextAdd(60,120,soot[0],fh2) <--- this would print "bla"


If you want acsess a spesific value in a array you just print: soot[y] and y = the place in the array you want to access.
Remember that when you initialise the array you write exactly how many "slots" it will have as you did here:  string soot[3] = {"bla", "bleh", "poo"}; but when you want to access them you begin from 0.

bous006

  • Guest
Re: Printing out values of an array
« Reply #2 on: January 11, 2013, 08:21:45 am »
Thanks, ill try it out.

bous006

  • Guest
Re: Printing out values of an array
« Reply #3 on: January 11, 2013, 09:49:52 am »
Could anyone tell me what "error C2665: 'TextAdd' : none of the 2 overloads could convert all the argument types" means?

DeadSn0wMan

  • Guest
Re: Printing out values of an array
« Reply #4 on: January 11, 2013, 10:02:28 am »
You need to give me some code of where you added the text

bous006

  • Guest
Re: Printing out values of an array
« Reply #5 on: January 11, 2013, 10:21:46 am »
Its all good, i changed the "string soot[3]" to char soot[3][500]" and it works fine, but thanks anyways.