printf %s integer in C

Asked

Viewed 358 times

0

I’m trying to make appear on the screen all characters of the string typePersonagem[0], but only the last letter of the string is coming out, someone helps me in what I’m missing?

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

char tipoPersonagem[3][100] = {{'Lutador'}, {'Ninja'}, {'Apelão'}};

int main()
{
    //Definição para acentos e cedilha
    setlocale(LC_ALL, "Portuguese");

    printf("%s.", tipoPersonagem[0]);

    return 0;
}

1 answer

1


As strings in C are defined with "(double quotes), while '(single quotes) are used to represent only a character. So the code stays:

char tipoPersonagem[3][100] = {{"Lutador"}, {"Ninja"}, {"Apelão"}};
  • was just that? our men worth kkkkk always used ' ' ' or " " when it looked visually more beautiful, did not know it had difference.

  • @Paulohenriquerodriguesgrund only that! Don’t forget to mark the answer as correct! Good night!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.