main(){ incluir_teste(); mostrar(); /* printf("Digite a matricula procurada: "); scanf("%d",&matricula); int posicao = buscar(matricula); system("cls"); if(posicao != -1){ printf("Item procurado:\n"); printf("Matricula: %d\n",aluno[posicao].matricula); printf("Nome: %s\n",aluno[posicao].nome); printf("Idade: %d",aluno[posicao].idade); }else{ printf("Nenhum dado encontrado"); } */ int i; for(i = 0;i < 2;i++){ int mat; printf("Digite a matricula a remover: "); scanf("%d",&mat); int pos_aluno = buscar(mat); remover2(pos_aluno); } int id_maior = obtem_nota("maior"); printf(" ALUNO COM MAIOR NOTA\n"); printf("------------------------\n"); printf(" Matricula: %d \n",aluno[id_maior].matricula); printf("------------------------\n"); printf(" Nome: %s\n",aluno[id_maior].nome); printf("------------------------\n"); printf(" Idade: %d\n",aluno[id_maior].idade); printf("------------------------\n"); printf(" Nota: %d\n",aluno[id_maior].nota); }
int main(int argc, char *argv[]) { struct sockaddr_in svc_address; struct sockaddr_in clnt_address; int svc_sockfd,clnt_sockfd,n; socklen_t clnt_len,svc_len; char matricula[TAM_MATRICULA+1]; double nota; svc_sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (svc_sockfd<0) { fprintf(stderr,"%s: erro em socket(): %s\n",argv[0],strerror(errno)); exit(1); } svc_len = sizeof(svc_address); bzero((char *)&svc_address,svc_len); svc_address.sin_family = AF_INET; svc_address.sin_addr.s_addr = INADDR_ANY; svc_address.sin_port = htons(SOCKET_PORT); if (bind(svc_sockfd,(struct sockaddr *)&svc_address,svc_len) < 0) { fprintf(stderr,"%s: erro em bind(): %s\n",argv[0],strerror(errno)); exit(1); } clnt_len = sizeof(clnt_address); while (1) { n = recvfrom(svc_sockfd,matricula,sizeof(char)*(TAM_MATRICULA+1),0,(struct sockaddr *)&clnt_address, &clnt_len); if (n < 0) { fprintf(stderr,"%s: erro em recvfrom(): %s\n",argv[0],strerror(errno)); exit(1); } nota = obtem_nota(matricula); n = sendto (svc_sockfd, (char *)¬a, sizeof(double), 0, (struct sockaddr *)&clnt_address, clnt_len); if (n < 0) { fprintf(stderr,"%s: erro em sendto(): %s\n",argv[0],strerror(errno)); exit(1); } } return(0); }