Added comments and makefile

This commit is contained in:
Dmitriy Shishkov 2020-06-11 13:56:38 +05:00
parent fb32150ef1
commit 3c12ad5db1
3 changed files with 23 additions and 2 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
.vscode .vscode
a.out a.out
triangle

3
Makefile Normal file
View File

@ -0,0 +1,3 @@
triangle: triangle.c
$(CC) triangle.c -o triangle -Wall -Wextra
./triangle

View File

@ -1,6 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h>
void clrscr(); void clrscr();
bool strcomp(char *a, char *b); bool strcomp(char *a, char *b);
@ -10,6 +11,9 @@ void getTriangleOptions(char *type);
int main() int main()
{ {
/*
Header
*/
clrscr(); clrscr();
printf("\n\n"); printf("\n\n");
printf(" * Welcom to The Triangle programm.\n"); printf(" * Welcom to The Triangle programm.\n");
@ -21,29 +25,39 @@ int main()
clrscr(); clrscr();
/*
Preview
*/
drawTriangle("so", 5, '*', '\0'); drawTriangle("so", 5, '*', '\0');
printf("(so)lid\n"); printf("(so)lid\n");
drawTriangle("st", 5, '*', '+'); drawTriangle("st", 5, '*', '+');
printf("(st)ripped\n"); printf("(st)ripped\n");
/*
Configuration
*/
printf("Select what mode do you want to work with: "); printf("Select what mode do you want to work with: ");
// Type
char type[3]; char type[3];
fgets(type, 3, stdin); fgets(type, 3, stdin);
printf("%s. Great choise!\n", ((type == "so") ? "Solid" : "Stripped")); printf("%s. Great choise!\n", (strcomp(type, "so") ? "Solid" : "Stripped"));
// Height
int height; int height;
printf("Height of triangle: "); printf("Height of triangle: ");
scanf("%d", &height); scanf("%d", &height);
getchar(); getchar();
// Primary symbol
char symbol1; char symbol1;
printf("Primary symbol: "); printf("Primary symbol: ");
symbol1 = getchar(); symbol1 = getchar();
getchar(); getchar();
// Secondary symbol
char symbol2; char symbol2;
if (strcomp(type, "st")) if (strcomp(type, "st"))
{ {
@ -51,6 +65,9 @@ int main()
symbol2 = getchar(); symbol2 = getchar();
} }
/*
Drawing
*/
drawTriangle(type, height, symbol1, symbol2); drawTriangle(type, height, symbol1, symbol2);
return 0; return 0;