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

void invCh1(char *, char *);
void invCh2(char *);

char *invCh3(char *);

int main()
{
    char *pal= "Entrez une chaine: !", buf[256];

    // Méthode pointeur
    invCh1(buf, pal);
    printf("\n%s\n%s\n", pal, buf);

    // Méthode tableau
    char tab[256], *ptab;

    strcpy(tab, pal);
    invCh2(tab);
    printf("\n%s\n%s\n", pal, tab);

    ptab= malloc(sizeof(char) * strlen(pal));
    strcpy(ptab, pal);
    ptab= invCh3(ptab);
    printf("\n%s\n%s\n", pal, ptab);

    return 0;
}

void invCh1(char *inv, char *tab)
{
    size_t taillebuf= strlen(tab);

    for(int i=0; tab[i]!= 0; i++)
    {
        inv[taillebuf-i-1]= tab[i];
    }
    inv[taillebuf]= 0;
}

void invCh2(char *t)
{
    char *tmp;
    size_t taillebuf= strlen(t);

    tmp= malloc(sizeof(char) * taillebuf);

    for(int i=0; t[i]; i++)
    {
        tmp[i]= t[taillebuf-i-1];
    }
    tmp[taillebuf]= 0;
    strcpy(t, tmp);
}

char *invCh3(char *tb)
{
    char *tmp;

    size_t taillebuf= strlen(tb);

    tmp= malloc(sizeof(char) * taillebuf);

    for(int i=0; tb[i]; i++)
    {
        tmp[i]= tb[taillebuf-i-1];
    }

    strcpy(tb, tmp);
    return tb;
}

Add a code snippet to your website: www.paste.org