APL/APL1.2/TP05/decomposition.c

26 lines
478 B
C
Raw Normal View History

2021-12-07 15:08:24 +01:00
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc, char * argv[]) {
int found = 0;
FILE* flux = fopen("rgb.txt", "r");
int r, g, b;
char name[100];
while (!feof(flux)) {
fscanf(flux, "%d %d %d\t\t%99[^\n]", &r, &g, &b, &name);
if (strcmp(name, argv[1]) == 0) {
found++;
printf("Color found : \x1B[38;2;%d;%d;%dm%d, %d, %d\x1B[37m.\n", r, g, b, r, g, b, name);
}
}
if (!found) puts("No color found...");
return EXIT_SUCCESS;
}