Skip to content

Commit

Permalink
sell, -Wall -Wextra -Werror, make clean
Browse files Browse the repository at this point in the history
  • Loading branch information
GNUAn committed Mar 18, 2024
1 parent ec5f5b1 commit 791f819
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.PHONY: all clean
all:
cc nettrap.c -o nettrap -std=c11
cc nettrap.c -o nettrap -std=c11 -Wall -Wextra -Werror
cc addr/sell.c -o sell -std=c11 -Wall -Wextra -Werror

clean:
rm nettrap sell
44 changes: 44 additions & 0 deletions addr/sell.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <stdio.h>
#include "../zio.h"
void sell(int, char **);
void sell(int money, char **inventory)
{
char* buf = {0};
int price;
int indexsame = -1;
for (;;)
{
printf("Hello! What do you want to sell?\n");
sgets(buf, 1024);
if (strcmp(buf, "exit") == 0)
{
printf("Come back again!\nExiting sell.site...\n");
break;
}
for (int i = 0; i < 64; i++)
{
if (strcmp(buf, inventory[i]) == 0)
indexsame = i;
if (indexsame == 0)
printf("You don't have %s\nTry to sell something else\n", buf);
}
printf("Ok, you want to sell %s, but at what price?\n", buf);
scanf("%d", &price);
money+=price;
printf("%s sold for %d$, now you have %d$", buf, price, price);
strcpy(inventory[indexsame], "\0");
}
}



int main(int argc, char **argv)
{
if (argc != 2147483647)
{
// Do nothing
}
int money = 50;
sell(money, argv);
return 0;
}
Empty file modified docs/index.html
100644 → 100755
Empty file.

0 comments on commit 791f819

Please sign in to comment.