Ir ao conteúdo

Whiplax

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

Tudo que Whiplax postou

  1. Quero entende porque isto funciona char c[30] = "testing"; char *p; *p = c[6]; printf("%c - %c", c[6], *p); //> g - g Porém isso da esse erro char c[30] = "testing"; char *p = c[6]; printf("%c - %c", c[6], *p); //>warning: initialization makes pointer from integer without a cast [-Wint-conversion] // char *p = c[6]; // ^ E também porque nesse caso aqui não consigo passar um char pro ponteiro void foo(char *s){;} int main(){ char c[30] = "testing"; foo(c);}// ou foo("g") //Isso funciona void foo(char *s){;} int main(){ char c[30] = "testing"; foo(c[6]);}// ou foo('g') //Isso não funciona //Para foo(c[6]); //warning: passing argument 1 of 'foo' makes pointer from integer without a cast [-Wint-conversion] // foo(c[6]); // ^ //note: expected 'char *' but argument is of type 'char' // void foo(char *s){ // ^~~ //Para foo('o'); //warning: passing argument 1 of 'foo' makes pointer from integer without a cast [-Wint-conversion] // foo('o'); // ^~~ //note: expected 'char *' but argument is of type 'int' // void foo(char *s){ // ^~~ Foi mal se tá mal formatado e se a pergunta é *****

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...