Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Retornar ponteiro para matriz bidimensional.


== Douplus ==

Pergunta

Três questões:

1-) Por que isso dá certo?

#include <stdio.h>

char **retarray(void)
{
  static char *abra[3][10] = { { "abra", "kadabra", "alakazam" }, 
                   { "bulbasaur", "ivysaur", "venusaur" }, 
                   { "um", "dois", "tres", "quatro" } };
  printf("%s\n", abra[0][0]);
  return abra[0];
}

int main(void)
{
  char **str;
  str = retarray();
  printf("%s\n", str[0]);
  return 0;
}
2-) Por que isso dá errado?
#include <stdio.h>

int **retarray(void)
{
  static int *tridmat[3][10] = { { { 3, 6, 9 } }, 
                  { { 12, 15, 18 } }, 
                  { { 21, 24, 27 } } };
  printf("%d\n", tridmat[0][0][0]);
  return tridmat[0];
}

int main(void)
{
  int **tridmat;
  tridmat = retarray();
  printf("%s\n", tridmat[0][0]);
  return 0;
}
bash-3.1$ gcc retarray.c -o retarray retarray.c: In function 'retarray': retarray.c:5: warning: braces around scalar initializer retarray.c:5: warning: (near initialization for 'tridmat[0][0]') retarray.c:5: warning: initialization makes pointer from integer without a cast retarray.c:5: warning: excess elements in scalar initializer retarray.c:5: warning: (near initialization for 'tridmat[0][0]') retarray.c:5: warning: excess elements in scalar initializer retarray.c:5: warning: (near initialization for 'tridmat[0][0]') retarray.c:6: warning: braces around scalar initializer retarray.c:6: warning: (near initialization for 'tridmat[1][0]') retarray.c:6: warning: initialization makes pointer from integer without a cast retarray.c:6: warning: excess elements in scalar initializer retarray.c:6: warning: (near initialization for 'tridmat[1][0]') retarray.c:6: warning: excess elements in scalar initializer retarray.c:6: warning: (near initialization for 'tridmat[1][0]') retarray.c:7: warning: braces around scalar initializer retarray.c:7: warning: (near initialization for 'tridmat[2][0]') retarray.c:7: warning: initialization makes pointer from integer without a cast retarray.c:7: warning: excess elements in scalar initializer retarray.c:7: warning: (near initialization for 'tridmat[2][0]') retarray.c:7: warning: excess elements in scalar initializer retarray.c:7: warning: (near initialization for 'tridmat[2][0]') bash-3.1$
3-) E, finalmente, por que isso dá errado?
#include <stdio.h>

int **retarray(void)
{
  static int tridmat[3][3][10] = { { { 3, 6, 9 } }, 
                  { { 12, 15, 18 } }, 
                  { { 21, 24, 27 } } };
  printf("%d\n", tridmat[0][0][0]);
  return tridmat[0];
}

int main(void)
{
  int **tridmat;
  tridmat = retarray();
  printf("%s\n", tridmat[0][0]);
  return 0;
}

bash-3.1$ gcc retarray.c -o retarray

retarray.c: In function 'retarray':

retarray.c:9: warning: return from incompatible pointer type

bash-3.1$ ./retarray

3

Segmentation fault

bash-3.1$

Editado por == Douplus ==
Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

  • 0

Isso deu certo????

#include <stdio.h>

char **retarray(void)
{
  static char *abra[3][10] = { { "abra", "kadabra", "alakazam" },
                   { "bulbasaur", "ivysaur", "venusaur" },
                   { "um", "dois", "tres", "quatro" } };
  printf("%s\n", abra[0][0]);
  return abra[0];
}

int main(void)
{
  char **str;
  str = retarray();
  printf("%s\n", str[0]);
  return 0;
}
Que compilador você usa? Aqui no gcc não funciona. Tenta esse código aqui pra ver se funciona:
int **retarray(void)
{
  static int **tridmat;
  
  tridmat = (int**) malloc(3 * sizeof(int*));
  for(int i=0; i<3; i++) tridmat[i] = (int*) malloc(10 * sizeof(int));
  
  tridmat[0][0] = 3;
  tridmat[0][1] = 6;
  tridmat[0][2] = 9;
  
  printf("%d\n", tridmat[0][0]);
  return tridmat;
}

int main(void)
{
  int **tridmat;
  tridmat = retarray();
  printf("%d\n", tridmat[0][1]);
  return 0;
}

Abraço.

Link para o comentário
Compartilhar em outros sites

  • 0
Isso deu certo????

#include <stdio.h>

char **retarray(void)
{
  static char *abra[3][10] = { { "abra", "kadabra", "alakazam" },
                   { "bulbasaur", "ivysaur", "venusaur" },
                   { "um", "dois", "tres", "quatro" } };
  printf("%s\n", abra[0][0]);
  return abra[0];
}

int main(void)
{
  char **str;
  str = ret[array();
  printf("%s\n", str[0]);
  return 0;
}
Que compilador você usa? Aqui no gcc não funciona.
Sim, isso deu certo, tou usando o gcc version 4.3.3 (GCC).
Tenta esse código aqui pra ver se funciona:
int **retarray(void)
{
  static int **tridmat;
  
  tridmat = (int**) malloc(3 * sizeof(int*));
  for(int i=0; i<3; i++) tridmat[i] = (int*) malloc(10 * sizeof(int));
  
  tridmat[0][0] = 3;
  tridmat[0][1] = 6;
  tridmat[0][2] = 9;
  
  printf("%d\n", tridmat[0][0]);
  return tridmat;
}

int main(void)
{
  int **tridmat;
  tridmat = retarray();
  printf("%d\n", tridmat[0][1]);
  return 0;
}
Abraço.
Eu queria que fosse uma matriz estática mesmo, não quero que realoque toda vez que chame a função. Eu descobrí um macete para dar certo, mas é bem estranho... Consiste em definir o int[3][3] ou int[3] como um novo tipo:
#include <stdio.h>

typedef int mask[3];

mask *retarray(void)
{
  static mask tridmat[3][3] = { { { 3, 6, 9 } },
                  { { 12, 15, 18 } },
                  { { 21, 24, 27 } } };
  printf("%d\n", tridmat[0][0][0]);
  return tridmat[0];
}

int main(void)
{
  mask *tridmat;
  tridmat = retarray();
  printf("%d\n", tridmat[0][0]);
  return 0;
}

Parece que uma função em C++ só retorna ponteiros e não arrays... Estranhíssimo, mas funciona.

Obrigado e qualquer nova informação poste aí!

Editado por == Douplus ==
Link para o comentário
Compartilhar em outros sites

  • 0
Sim, isso deu certo, tou usando o gcc version 4.3.3 (GCC).
Testei pela segunda vez agora e deu certo (???). Acho que fiz alguma coisa errada na primeira vez.

Eu queria que fosse uma matriz estática mesmo, não quero que realoque toda vez que chame a função.

Bom eu não entendi o objetivo dessa função, pensei que era para criar a matriz. De fato é uma alternativa meio estranha, mas se funciona ai tá valendo.

Abraço.

Link para o comentário
Compartilhar em outros sites

  • 0

A verdade é que eu estou fazendo um joguinho da cobrinha por diversão e queria uma função que recebe o número do level e retorna o mapa (onde tem as paredes). Tá ficando alguma coisa assim (acho que se exemplificar você entende melhor :-):

Stage *loadstage(short num)
{
  static Stage stageVec[3] = { { { 1,1,1,1,1,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, 
  { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, 
  { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, 
  { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, 
  { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, 
  { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, 
  { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, 
  { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } } };
return ((num < LEVELS) ? (stageVec + num) : NULL);
}

Link para o comentário
Compartilhar em outros sites

  • 0
se isso for para jogo ou alguma coisa parecida posso te ajudar por que isso ai ta dificil em ... (se duvida nem o PC vai conseguir ler) brinks xD

se quiser add eu no MSN te ajudo a melhorar isso

Hihihih.. É só formatar direitinho no editor que faz sentido :-)

É que eu tava sem nada pra fazer sexta à noite e resolví fazer um jogo da cobrinha literalmente da noite para o dia, só para passar o tempo, sem comprometimento, por isso deixei os levels na RAM mesmo. Porém, acabei gastando mais tempo porque nunca tinha mexido com OpenGL. Agora eu já estou "nos finalmentes'", mas o jeito que a OpenGL funciona me fez mudar todo o código todo e perder a lógica inicial.

Se você quiser conversar eu já vou montando meu formulário de questões aqui... Ahah!

P.S.: Rí demais do seu avatar.

Editado por == Douplus ==
Link para o comentário
Compartilhar em outros sites

  • 0
se isso for para jogo ou alguma coisa parecida posso te ajudar por que isso ai ta dificil em ... (se duvida nem o PC vai conseguir ler) brinks xD

se quiser add eu no MSN te ajudo a melhorar isso

Hihihih.. É só formatar direitinho no editor que faz sentido :-)

É que eu tava sem nada pra fazer sexta à noite e resolví fazer um jogo da cobrinha literalmente da noite para o dia, só para passar o tempo, sem comprometimento, por isso deixei os levels na RAM mesmo. Porém, acabei gastando mais tempo porque nunca tinha mexido com OpenGL. Agora eu já estou "nos finalmentes'", mas o jeito que a OpenGL funciona me fez mudar todo o código todo e perder a lógica inicial.

Se você quiser conversar eu já vou montando meu formulário de questões aqui... Ahah!

P.S.: Rí demais do seu avatar.

use a app allegro ela e facil e muito bom para fazer jogos 2D tenho 2 programas aqui no scriptbrasil em dicas la em cima ... de uma passada la xD

sim microsoft cada vez mais lixeira ....

Editado por ce1o2e
Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,4k
×
×
  • Criar Novo...