orneto

temp

Dec 8th, 2019
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int menu(){
  5. printf("escolha uma opcao:\n"
  6. "1 - Adicionar novo item\n"
  7. "2 - Buscar um item\n"
  8. "3 - Remover um item\n"
  9. "4 - Mostrar toda a lista\n"
  10. "5 - Salvar os itens em um arquivo .txt\n"
  11. "6 - Ler os itens de um arquivo .txt\n"
  12. "7 - Ordenar itens por Nome\n"
  13. "8 - Ordenar itens por Preco\n");
  14. }
  15. struct pedidos{
  16. char item[99];
  17. float preco;
  18. int quantidade;
  19. };
  20. typedef struct pedidos pedidos;
  21. pedidos novoitem(){
  22. pedidos aux;
  23. scanf("%s", &aux.item);
  24. scanf("%f", &aux.preco);
  25. scanf("%d", &aux.quantidade);
  26. return aux;
  27. }
  28. struct lista {
  29. pedidos info;
  30. struct lista* prox;
  31. };
  32. typedef struct lista lista;
  33. lista* inserir(lista* Lista, pedidos info){
  34. lista* novo = malloc(sizeof(lista));
  35. novo->info = info;
  36. novo->prox = Lista;
  37. return novo;
  38. }
  39.  
  40. int main() {
  41. lista* test;
  42. test=malloc(sizeof(lista));
  43. pedidos teste;
  44. teste = novoitem();
  45. inserir(test, teste);
  46. printf("%d\n", test->info.quantidade);
  47. menu();
  48. return 0;
  49. }
Add Comment
Please, Sign In to add comment