
raphamolnar
(usa Ubuntu)
Enviado em 30/05/2011 - 14:05h
Galerinha estou com muitas dúvidas sobre struct, vi vários exemplos porém nenhum rodou no meu compilador.
O ultimo que visualizei foi o seguinte link:
http://www.vivaolinux.com.br/script/Estrutura-typedef-struct-em-C
e me retornou a seguinte mensagem:
raphaelmolnar@RaphaelMolnar:~/C++$ g++ teste_struct.c -o teste_struct
teste_struct.c: In function ‘int main()’:
teste_struct.c:20: warning: format ‘%s’ expects type ‘char*’, but argument 2 has type ‘char (*)[15]’
teste_struct.c:22: warning: format ‘%s’ expects type ‘char*’, but argument 2 has type ‘char (*)[15]’
teste_struct.c:24: warning: format ‘%s’ expects type ‘char*’, but argument 2 has type ‘char (*)[15]’
Tenho também um código que tentei compilar porém também retornou um monte de erros se alguém puder me apontar onde estou errando seria de grande ajuda . . . desde já agradeço
segue o código que estou tentando fazer funcionar
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int idade(){
int idade;
printf("Digite a 1 idade ");scanf("%i", idade);
printf("\n\n");
return idade;}
string nome(){
string nome;
printf("Digite o 1 nome "); scanf("%s", nome);
printf("\n\n");
return nome;}
int telefone(){
int telefone;
printf("Digite o 1 telefone "); scanf("%i", telefone);
printf("\n\n");
return telefone;}
typedef struct
{int age;int tell;string name;}registro;
//registro age; registro tell; registro name;
int main(){
registro;
for(int i=1;i=10;i++)
{printf("%s,%s,%s", registro.name[i]=nome(),registro.age[i]=idade(),registro.tell[i]=telefone()"\n");}
getchar();
return EXIT_SUCCESS;}