467,104 Members | 1,054 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

count characteres of <stdin> at input time

Hi,
I'd like to know how I cancount characters user inputs while they input it.
Imagine something like this:
See this example how this could work:

input your title (2 chars):
My

input your title (8 chars):
My Title

input your title (11 chars):
My Title is


If this isn't possible I'd like to truncate the input to some number of chars (like in sms, can't write more than n chars)

Can Somebody give me an hand?

Thanks,

Jo„o Correia
Sep 16 '08 #1
  • viewed: 2365
Share:
3 Replies
KevinADC
Expert 2GB
I don't know how you could count the characters while they are being inputted, but you can use the substr() function to truncate a string. You can also use the length() function to determine the length of a string.
Sep 17 '08 #2
I'm using the length( ) function to get the lenght of the input, but only after the <ENTER>.
This way the user have to insert everything again...

Maybe I can force the input to be less than 10 chars, can I give the length of the input before reading it from keyboard?
Sep 17 '08 #3
KevinADC
Expert 2GB
I'm using the length( ) function to get the lenght of the input, but only after the <ENTER>.
This way the user have to insert everything again...

Maybe I can force the input to be less than 10 chars, can I give the length of the input before reading it from keyboard?
If you can I have no idea how.
Sep 17 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

31 posts views Thread by da Vinci | last post: by
17 posts views Thread by Christoph Scholtes | last post: by
232 posts views Thread by robert maas, see http://tinyurl.com/uh3t | last post: by
1 post views Thread by jcor | last post: by
77 posts views Thread by arnuld | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.