I'm trying to create a program in C that prints the letters from alphabet that are not in gussed_character. All unused letters are saved in available_character.
Code:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
void letters(const char gussed_character[], char available_character[]){
char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
int gussed_character_lenght = strlen(gussed_character);
int alphabet_lenght = strlen(alphabet);
int counter = 0;
for(int i = 0; i<alphabet_lenght; i ){
counter = 0;
for(int j = 0; j<gussed_character_lenght; j ){
if(alphabet[i] != gussed_character[j]){
counter ;
}
if(counter == gussed_character_lenght){
available_character[i] = alphabet[i];
}
}
}
printf("%s", available_character);
}
int main(){
char result[30];
letters("arpstxgoieyu", result);
}
Example from code:
letters("arpstxgoieyu", result);
This letters are used and prgram should print this letters:
bcdfhjklmnqvwz
But my program print this: