Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int menu(){
- printf("escolha uma opcao:\n"
- "1 - Adicionar novo item\n"
- "2 - Buscar um item\n"
- "3 - Remover um item\n"
- "4 - Mostrar toda a lista\n"
- "5 - Salvar os itens em um arquivo .txt\n"
- "6 - Ler os itens de um arquivo .txt\n"
- "7 - Ordenar itens por Nome\n"
- "8 - Ordenar itens por Preco\n");
- }
- struct pedidos{
- char item[99];
- float preco;
- int quantidade;
- };
- typedef struct pedidos pedidos;
- pedidos novoitem(){
- pedidos aux;
- scanf("%s", &aux.item);
- scanf("%f", &aux.preco);
- scanf("%d", &aux.quantidade);
- return aux;
- }
- struct lista {
- pedidos info;
- struct lista* prox;
- };
- typedef struct lista lista;
- lista* inserir(lista* Lista, pedidos info){
- lista* novo = malloc(sizeof(lista));
- novo->info = info;
- novo->prox = Lista;
- return novo;
- }
- int main() {
- lista* test;
- test=malloc(sizeof(lista));
- pedidos teste;
- teste = novoitem();
- inserir(test, teste);
- printf("%d\n", test->info.quantidade);
- menu();
- return 0;
- }
Add Comment
Please, Sign In to add comment