Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Easiest way to input a string..

Credits go to miran for helping out!
This thread is locked; no one can reply to it. rss feed Print
Easiest way to input a string..
cdxrd
Member #7,061
March 2006

I'm sure Im going to get redirected to look at the libraries and add-ons, but I was hoping to avoid adding and learning another library just for one little thing. I have my high score list, and I need to allow the user to enter their name, up to 15 chars.

The way I was going to do it, would simply be to draw out all of the characters on screen, user clicks on em as needed, and use some form of string manipulation to add it to my array to be written back out. I figured if I stored clicks in an array, if they hit backspace, I could just set my counter back one, erase that letter, boom.

Would this be the easiest way?

edit: my limited little brain never even thought of using the kb to input. How stupid can I be.. =) I already have all my letters drawn .. I'm dumb!.. Thats a side note tho, I'll still allow mouse input.. heh

On another note, whats the easiest way to convert say from, char name[15] to say, string nameString ?

miran
Member #2,407
June 2002

Quote:

Easiest way to input a string..

With a keyboard. But I see you already figured that out yourself.

You could also use this: d_edit_proc();

Quote:

On another note, whats the easiest way to convert say from, char name[15] to say, string nameString ?

nameString = name;::)

--
sig used to be here

cdxrd
Member #7,061
March 2006

Thanks Miran, im tossing ideas around in my head while Im at work, and cant look up a lot of stuff online.. proxies.. =)

Not sure what all I was thinking and why I was making this 10 times more difficult for myself.. I drew up all the letters a couple weeks ago, and havent touched it since, dreading figuring out the coords for each letter and the checks needed.. whatg a pain I was making it.. I'm dumb!

Anyways..

Thanks for answering the one question tho miran, I know converting a String to a char[] needed a command, I figured I would need some function to go the opposite way as well.

Go to: