-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sell, -Wall -Wextra -Werror, make clean
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.