Jump to content
Fórum Script Brasil
  • 0

Guilherme.
 Share

Question

/*
    Aplicativo para criar um baralho, atribuir Naipes às cartas
    25/11/2015
*/

#include <stdio.h>
#define LINHA 3 //Define uma constante global para 'linha'
#define COLUNA 12 //Define uma constante global para 'coluna'

main(){
    
    int  inicia_cartas(); //Declara o escopo do método 'inicia_cartas'
    char cartas[LINHA][COLUNA]; //Cria um vetor bidimensional
    
    cartas = inicia_cartas(); // "[ERROR]ASSIGNMENT TO EXPRESSION WITH ARRAY"
    
    //Exibe cartas
    int i;
    for(i = 0; i <= LINHA; i++){
        int j;
        for(j = 0; j <= COLUNA; j++){
            printf("%c\n", cartas[j]);        
        }
    }
}

char  inicia_cartas(){ //[Error] conflicting types for 'inicia_cartas'
    
    char set_naipe(int);
    char set_card(int);
    char cartas[LINHA][COLUNA]; //cria vetor bidimensional local
    
    int i;
    for(i = 0; i <= LINHA; i++){
        int j;
        for(j = 0; j <= COLUNA; j++){
            cartas[j] = set_card(j) + set_naipe(i); //atribui carta e naipe
        }
        
    }
    
    return cartas;

//[Warning] return makes integer from pointer without a cast; 

[Warning] function returns address of local variable [-Wreturn-local-addr]
}
    
char set_naipe(int i){
    
    char *naipes[] = {"Copa", "Ouro", "Espada", "Paus"};
    return *naipes;
    
}
    
char set_card(int j){
        
    char *card[] = {"As de ", "Dois de ", "Tres de ", "Quatro de ", 
                    "Cinco de ", "Seis de ", "Sete de ", "Oito de ", 
                    "Nove de ", "Dez de ", "Valete de ", "Dama de ", "Rei de "};
    return *card[j];
        
}

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.1k
    • Total Posts
      647k
×
×
  • Create New...