简体   繁体   中英

C - printf(“%s”) show Symbols

I need your help because when I print the values ​​of atual->chave they return Symbols. this is the code:

void mostrar(struct tLdde *l, int modo)
{
    struct tItem *atual;
    char *chave;

    if(modo == CABECA)
    {
        atual = l->inicio;
        while(atual != NULL)
        {
            chave = atual->chave;
            printf("%s ", &chave);
            atual = atual->proximo;
        }
    }
    else
    {
        atual = l->final;
        while(atual != NULL)
        {
            chave = atual->chave;
            printf("%s ", &chave);
            atual = atual->anterior;
        }
    }
    printf("\n");

}

and this is the output:

Spea ?{ Obam?{ iPhoP?{ Pott8?{

use

printf("%s ", chave);

and not

printf("%s ", &chave);

remove the &

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM