Загрузка страницы

PROGRAMA DE CADASTRO EM C - TUTORIAL PASSO A PASSO (2024)

Vídeo onde eu ensino do zero como você faz para criar um programa/sistema de cadastro simples na linguagem de programação C. O vídeo original tem mais de 1 hora de duração, eu tive que me esforçar muito para diminuir para 16 minutos sem que a explicação ficasse ruim.
Aproveitem!

CÓDIGO FEITO NO VÍDEO (tive que retirar os símbolos de "menor que" e "maior que" e substituir pela palavra, pois o youtube não permite na descrição):

#include menor que stdio.h maior que
#include menor que string.h maior que

typedef struct {
char Name[50];
float Price;
int Quantity;
}Product;

typedef struct {
int Id;
Product Products[99];
float Total;
}Order;

int main() {
int status = 1, id = 0, c;
Order orders[99];

while(status) {
printf("\e[1;1H\e[2J");

printf("\nChoose an option: ");
int option;
scanf("%d", &option);

switch(option) {
case 1:
printf("\e[1;1H\e[2J");

orders[id].Id = id;
printf("\nOrder ID: %d", id + 1);

float total = 0;

for(int i = 0; i menor que 99; i++){
while((c = getchar()) != '\n' && c != EOF);

printf("\nEnter the name of the product: ");
char name[50];
fgets(name, sizeof(name), stdin);

printf("\nEnter the price of the product: ");
float price;
scanf("%f", &price);

printf("\nEnter the quantity of the product: ");
int quantity;
scanf("%d", &quantity);

Product product = {.Price = price, .Quantity = quantity};
strcpy(product.Name, name);

orders[id].Products[i] = product;

total += price * quantity;

printf("\nDo you want to add another product? [y/n] ");
char newProduct;
scanf(" %c", &newProduct);

if (newProduct != 'y'){
break;
}
}
orders[id].Total = total;
id++;
break;
case 2:
printf("\e[1;1H\e[2J");
for(int i = 0; i menor que id; i++){
printf("\nOrder ID: %d", i + 1);

for(int j = 0; j menor que 99; j++){
printf("\nProduct #%d", j + 1);

printf("\nProduct's name: %s", orders[i].Products[j].Name);
printf("\nProduct's price: %f", orders[i].Products[j].Price);
printf("\nProduct's quantity: %d", orders[i].Products[j].Quantity);

if(orders[i].Products[j + 1].Quantity == 0){
break;
}
}
printf("\nTotal: %f", orders[i].Total);
}
printf("\nPress any key to continue...");
while((c = getchar()) != '\n' && c != EOF);
getchar();
break;
case 3:
status = 0;
break;
}
}
return 0;
}

CÓDIGO "EMBELEZADO", FORMATADO E COMENTADO:
https://github.com/Abnersampf/Simple-Purchasing-Program/blob/main/test.c

00:00 - Apresentação do programa
01:46 - Início do programa
01:55 - Criando as duas Structs
03:01 - Loop que controla o programa
04:07 - Controlando o encerramento do programa
04:17 - Criando o cadastro
10:28 - Criando a listagem
14:09 - Ajustes finais
15:02 - Rodando o programa
16:33 - Fim

Видео PROGRAMA DE CADASTRO EM C - TUTORIAL PASSO A PASSO (2024) канала mPOV
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
22 ноября 2023 г. 23:22:45
00:16:37
Яндекс.Метрика