• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Converting Letters to Ascii

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read the thread a couple lines down, but that did not help me (at least I don't think it did...). I'm reading in from a file, and when it sees a letter between A-Z, it stores the value that comes with the letter into an array of length 26. I'm confused how to correspond A with position 0 and so forth.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that char are a numeric type, so you can perform math on them. E.g.
 
Takumi Fujiwara
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I'm still having some trouble with this. What's suppose to happen is the program reads in strings from a file and tokenizes them via StringTokenizer. Then within the file read in, there will be variables between A-Z. Those variables need to be read in and changed to ints so that they can correspond with an array.



As you can see, there are various mistakes. I'm having trouble changing the variables A-Z to ints, and then giving them a position in the array letters. IE: A = 0, B = 1... Z = 25.

Edit: Disregard this. I figured it out. But I'll leave it if people get bored and wish to debug that or something.
[ May 22, 2004: Message edited by: Takumi Fujiwara ]
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic