By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

count characteres of <stdin> at input time

P: 63
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
Share this Question
Share on Google+
3 Replies


KevinADC
Expert 2.5K+
P: 4,059
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

P: 63
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 2.5K+
P: 4,059
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.