10 Replies - 1458 Views - Last Post: 30 September 2001 - 08:25 PM Rate Topic: -----

#1 blutrane  Icon User is offline

  • 私もクールです

Reputation: 25
  • View blog
  • Posts: 1,934
  • Joined: 17-May 01

trying to clear and input data into an array...

Posted 29 September 2001 - 10:15 AM

all i get are symbols if change i to 48 and i<=58 i get an illegal operation
 for(r=0; r<=3; r++)
{for(i=0; i<=10; i++)
 {cout<<(rou[(r*10)+i]=(r*10)+i);}}


Is This A Good Question/Topic? 0
  • +

Replies To: trying to clear and input data into an array...

#2 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 3509
  • View blog
  • Posts: 27,641
  • Joined: 21-March 01

Re: trying to clear and input data into an array...

Posted 29 September 2001 - 10:25 AM

Quote

Quote: from blutrane on 12:15 pm on Sep. 29, 2001
all i get are symbols if change i to 48 and i<=58 i get an illegal operation
 for(r=0; r<=3; r++)
{for(i=0; i<=10; i++)
 {cout<<(rou[(r*10)+i]=(r*10)+i);}}


ok, i dont think you can do the parentheses inside the bracket part of the array, and on you post i see a ] after the semicolon, put in the box im typing in, i see 2 }'s so maybe that might have something to do with it also.
Was This Post Helpful? 0
  • +
  • -

#3 blutrane  Icon User is offline

  • 私もクールです

Reputation: 25
  • View blog
  • Posts: 1,934
  • Joined: 17-May 01

Re: trying to clear and input data into an array...

Posted 29 September 2001 - 10:29 AM

it don't work the 2 parenthesis are for the loops
Was This Post Helpful? 0
  • +
  • -

#4 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 3509
  • View blog
  • Posts: 27,641
  • Joined: 21-March 01

Re: trying to clear and input data into an array...

Posted 29 September 2001 - 10:33 AM

{cout<<(rou[(r*10)+i]=(r*10)+i);}}


the parentheses tthat the r*10 are in... maybe, they cant work inside the array.
Was This Post Helpful? 0
  • +
  • -

#5 blutrane  Icon User is offline

  • 私もクールです

Reputation: 25
  • View blog
  • Posts: 1,934
  • Joined: 17-May 01

Re: trying to clear and input data into an array...

Posted 30 September 2001 - 12:22 PM

still only get symbols
Was This Post Helpful? 0
  • +
  • -

#6 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: trying to clear and input data into an array...

Posted 30 September 2001 - 01:09 PM

can you post the declaration of your array. Something doesn't seem right with this multiplication thing
Was This Post Helpful? 0
  • +
  • -

#7 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 3509
  • View blog
  • Posts: 27,641
  • Joined: 21-March 01

Re: trying to clear and input data into an array...

Posted 30 September 2001 - 01:13 PM

yea, im getting the same vibe.... dont know though..
Was This Post Helpful? 0
  • +
  • -

#8 blutrane  Icon User is offline

  • 私もクールです

Reputation: 25
  • View blog
  • Posts: 1,934
  • Joined: 17-May 01

Re: trying to clear and input data into an array...

Posted 30 September 2001 - 03:58 PM

its just a regular array
char rou[37];
Was This Post Helpful? 0
  • +
  • -

#9 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: trying to clear and input data into an array...

Posted 30 September 2001 - 05:35 PM

Ok, forgive me if I'm being dense...but what's the point of this code block? It seems to me that all you're doing is trying to set all the indices of rou[] to the value of each index, i.e. rou[0] = 0
In addition to this, if your array is only of length 37, then why, at their maximum values, does r*10 + i = 40?
And one last thing...what does "all i get are symbols" mean, exactly? If you mean, you get stuff other than the alphanumeric characters, then yes, I can see that. Say you set a character variable equal to an integer, as in:
char theChar = 10;
cout << theChar;
Your output won't be:
10
It'll actually treat the integer "10" as an ASCII code. This is typecasting - when possible, C++ will cast a value that is not the "correct" type to the "correct" one. In this case, it does this my using the value as the ASCII code -- not by "translating" the value into its ASCII code, and storing it. That's how chars are stored -- as ASCII codes.

Let me know how this goes.

-Malkiri

Was This Post Helpful? 0
  • +
  • -

#10 Teckwiz  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 120
  • Joined: --

Re: trying to clear and input data into an array...

Posted 30 September 2001 - 08:15 PM

Add  47,  or 48   to (r*10)+i,   to get the correct decimal numbers,  because doing this meathod starts at decimal symbol  0 and goes to 37,  but  you need to add 48  to start at the  deciamal  characters for number symbols 48-57

((r*10)+i)+48)

Was This Post Helpful? 0
  • +
  • -

#11 blutrane  Icon User is offline

  • 私もクールです

Reputation: 25
  • View blog
  • Posts: 1,934
  • Joined: 17-May 01

Re: trying to clear and input data into an array...

Posted 30 September 2001 - 08:25 PM

Quote

Quote: from malkiri on 8:35 pm on Sep. 30, 2001
Ok, forgive me if I'm being dense...but what's the point of this code block? It seems to me that all you're doing is trying to set all the indices of rou[] to the value of each index, i.e. rou[0] = 0
In addition to this, if your array is only of length 37, then why, at their maximum values, does r*10 + i = 40?
And one last thing...what does "all i get are symbols" mean, exactly? If you mean, you get stuff other than the alphanumeric characters, then yes, I can see that. Say you set a character variable equal to an integer, as in:
char theChar = 10;
cout << theChar;
Your output won't be:
10
It'll actually treat the integer "10" as an ASCII code. This is typecasting - when possible, C++ will cast a value that is not the "correct" type to the "correct" one. In this case, it does this my using the value as the ASCII code -- not by "translating" the value into its ASCII code, and storing it. That's how chars are stored -- as ASCII codes.

Let me know how this goes.

-Malkiri


i know that. that's the *10 is for ascii numbers go 0-9 and then can multiply them so 0-36

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1