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

repetitive strings

P: 6

i am not able to write a program which checks for the repetitive character string.
eg. if i enter Sandra..the program should give me an error if i type 'a' at 6th all alphabets should be unique.
Kindly help..Its urgent.

Mar 22 '07 #1
Share this Question
Share on Google+
2 Replies

P: 99
well, you can take your string and remove the first character from it and put it in another variable all by itself so that you have "S" and "andra."

then search for the single character in whatever you have left, if you find it, give the error. repeat this for every character, and you will be able to do it.

(the second run would split into "a" and "ndra". since you find the single character in the rest of what you have left, you know to give the error.)
Mar 22 '07 #2

Expert 2.5K+
P: 3,652
You could also use a series of nested for... loops. The first will be checking every character of the string. The second will be checking every character in the string after the character in the first loop. If at any time the two characters are the same, you have a repeat and you should give the error.
Mar 22 '07 #3

Post your reply

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