Skip to content

Instantly share code, notes, and snippets.

@dennermiranda
Created September 7, 2011 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennermiranda/1201599 to your computer and use it in GitHub Desktop.
Save dennermiranda/1201599 to your computer and use it in GitHub Desktop.
Trabalho prog
#include <stdio.h>
#include <stdlib.h>
struct item_agenda
{
char *nome;
int idade;
char sexo;
float ira;
char fone[10];
char email[200];
};
int ultimo, i, pos;
char nome[256];
struct item_agenda p[1000];
void shift(pos)
{
for (i = pos; i<1000; i++)
{
p[i+1] = p[i];
}
}
void incluir ()
{
printf ("Digite o nome");
gets(nome);
pos = position(nome);
shift(pos);
p[pos].nome = nome;
printf ("Digite a idade");
scanf ("%*d", p[ultimo].idade);
printf ("Digite o sexo (F ou M)");
scanf ("%*c", p[ultimo].sexo);
getchar();
printf ("Digite o ira");
scanf ("%*f", p[ultimo].ira);
getchar();
printf ("Digite o telefone");
gets(p[ultimo].fone);
printf ("Digite o email");
gets(p[ultimo].email);
}
int position(char n[256])
{
int menor;
for (i = 0; i<1000; i++)
{
if (p[0].nome[0] < n[0])
menor = i;
}
}
int main()
{
ultimo = 0;
incluir();
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment