Error Unknown type name 'typeTelephone'

Asked

Viewed 575 times

3

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

typedef struct{
    int id;
    char nome[20];
    tipoTelefone telefone;
}tipoCliente;

typedef struct{
    int x1;
    int x2;
    int x3;
    int x4;
    char digito;
    int y1;
    int y2;
    int y3;
    int y4;
}tipoTelefone;

int main(){
    int n,q,i,j,cont;
    char teste;
    printf("Qtds:\n");
    scanf("%d %d",&n,&q);

    tipoCliente cliente[n];

    for(i = 0; i < n; i++){
        scanf("%d %s %d%d%d%d%s%d%d%d%d",&cliente[i].id,&cliente[i].nome,&cliente[i].telefone.x1,&cliente[i].telefone.x2,&cliente[i].telefone.x3,&cliente[i].telefone.x4,&cliente[i].telefone.digito,&cliente[i].telefone.y1,&cliente[i].telefone.y2,&cliente[i].telefone.y3,&cliente[i].telefone.y4);
    }

//  for(j = 0; j < q; j++){
//      scanf("%d",&q_id);
//  }
//  
//  for(i = 0; i < n - 1; i++){
//      if(strcmp(cliente[i].nome,cliente[i + 1].nome) < 0){
//          
//      }else if(strcmp(cliente[i].nome,cliente[i + 1].nome) == 0){
//          if(cliente[i].id > cliente[i + 1].id){
//              
//          }
//      }
//  }

    printf("\n");
    for(i = 0; i < n; i++){
        printf("%d %s %d%d%d%d%s%d%d%d%d",cliente[i].id,cliente[i].nome,cliente[i].telefone.x1,cliente[i].telefone.x2,cliente[i].telefone.x3,cliente[i].telefone.x4,cliente[i].telefone.digito,cliente[i].telefone.y1,cliente[i].telefone.y2,cliente[i].telefone.y3,cliente[i].telefone.y4);
    }

    return 0;
}

Erro apresentado ao compilar o código

1 answer

4


You are using a type created after its use, at this point the anida compiler does not know that you will create there in front, need to put the statements in the right order, then declare the tipoTelefone before you solve this problem.

This guy looks really weird, at least he should change int for char to take up less space. I would still do otherwise using a string.

  • I did it because I can’t think of a way to receive a phone number in the format xxxx-yyyy and with that phone number, make the following sum: xxxx+yyyy. If you have a tip, I’d appreciate it. Anyway, I appreciate the help.

  • I can’t imagine why I would make this sum. https://answall.com/q/47871/101.

  • To suit the criteria of a program I am doing. The criterion is that for each client, the sum xxxx + yyyy is calculated. Then, the rest of this sum is calculated in the division by 7, that is, the result value is a number between 0 and 6. The client that has the lowest value must be called first

  • Wow, that’s a crazy requirement, but anyway there are better ways to build this, but that’s another subject that I don’t even want.

  • College stuff, man. Anyway, you’ve helped a lot with the struct error. Thanks!

  • at least change the type int for char to save space.

Show 1 more comment

Browser other questions tagged

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