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

repetitive strings

P: 6
Hello,

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 position...ie all alphabets should be unique.
Kindly help..Its urgent.

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


Roonie
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

Ganon11
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.