pendu langage c

Sure! Here is an example of a pendu game implemented in the C programming language:

#include <stdio.h>
#include <string.h>

#define MAX_TRIES 6

int main() {
    char secretWord[100];
    char guessedWord[100];
    int length, tries = 0, i, found = 0;

    printf("Enter the secret word: ");
    scanf("%s", secretWord);

    length = strlen(secretWord);

    // Initialize the guessedWord with underscores
    for (i = 0; i < length; i++) {
        guessedWord[i] = '_';
    }
    guessedWord[length] = '\0';

    while (tries < MAX_TRIES && strcmp(secretWord, guessedWord) != 0) {
        printf("\n%s\n", guessedWord);
        printf("Enter a letter: ");
        char guess;
        scanf(" %c", &guess);

        found = 0;

        for (i = 0; i < length; i++) {
            if (secretWord[i] == guess) {
                guessedWord[i] = guess;
                found = 1;
            }
        }

        if (!found) {
            tries++;
            printf("Wrong letter! Tries left: %d\n", MAX_TRIES - tries);
        }
    }

    if (strcmp(secretWord, guessedWord) == 0) {
        printf("\nCongratulations! You guessed the word: %s\n", secretWord);
    } else {
        printf("\nGame over! You failed to guess the word: %s\n", secretWord);
    }

    return 0;
}

This is a simple implementation of the "pendu" game (also known as "hangman") in the C programming language. The player is prompted to enter a secret word, and then they have to guess letters of the word one by one. The number of incorrect guesses is limited to 6 (as defined by the MAX_TRIES constant). If the player guesses all the letters correctly before running out of tries, they win the game. Otherwise, they lose.

Please note that this is just a basic implementation and can be further enhanced with additional features like checking input validity, displaying a visual representation of the hangman, or allowing the player to choose different difficulty levels.