[HELP] Check if "Just do it" is in users input
Make and run a program that will accept a user input of not more than 50 characters and find set of letters that will produce the string “just do it” consecutively. The program should output the string “just do it” or “string not found” if the entered words were unable to produce the desired string.
The problem in my work is if the letters in "JUST DO IT" is found even if it is not consecutive or it counted more than one of the same letter, it still says that it found "Just do it".
This is what I have so far!
Code:
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int
main(void)
{
char word[51];
const char just_do_it[] = "JUST DO IT";
int correctness = 0;
gets(word);
for (int i = 0; i < 40; i++)
{
word[i] = toupper(word[i]);
for (int j = 0; j < 10; j++)
{
if (word[i] == just_do_it[j])
correctness++;
}
}
if (correctness == 10)
printf("\nJust do it.\n");
else
printf("\nString not found\n");
return 0;
}