0
Logical Error!!!
Why My Program can't produce the desired output!? /* Program to find out if an input String contain consecutive duplicate characters */ #include <stdio.h> #include <stdbool.h> #include <string.h> bool Find_Repeat (char* Rcharacters) { for(int i = 0; i < strlen(Rcharacters); i++) { int j = i + 1; if(Rcharacters[i] == Rcharacters[j]) return 1; } return 0; } int main() { char Random_Characters[100]; printf ("\n Enter Random Characters --> "); scanf("%[^\n]s",Random_Characters); if (Find_Repeat (Random_Characters)) printf ("\n Repeated Found!"); else printf ("\n Unique"); return 0; }
3 Answers
+ 2
Seems to be working as designed. When a string of characters is entered without any immediate repeats the output is "Unique". If there is an immediate repeat of a character in the string then the output is "Repeated Found!".
What issue are you having? Give an example with input and expected output.
+ 2
ChaoticDawg Yeah, You're Right!!!!
Actually I wrote this Code as part of the Code Coach Challenges, now I tested it again the problem was how input/output should be arranged!!! And I didn't pay enough attention! I'm sorry, accept my apologies đ
+ 1
No worries