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; }

5th Jan 2021, 12:04 AM
H. Ahmadian
H. Ahmadian - avatar
3 odpowiedzi
+ 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.
5th Jan 2021, 1:00 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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 🙏
5th Jan 2021, 1:24 AM
H. Ahmadian
H. Ahmadian - avatar
+ 1
No worries
5th Jan 2021, 1:25 AM
ChaoticDawg
ChaoticDawg - avatar