#include #include #include #include char* rightshift(char* data, size_t size) { char* res = malloc(size * sizeof(char)); *res = ' '; memcpy(res + 1, data, size - 1); free(data); return res; } // Graph with have a height of 10 characters and width of 12 int printgraph(int max, int inuse, char** graphdata, char prog, char* yaxis, char* xaxis) { float percentage = ((float)inuse)/((float) max); int percent = floorf(percentage * 10); printf("%d\n", percent); for (int i = 9; i > 0; i--) { graphdata[i] = rightshift(graphdata[i], 12); if (percent == i) { graphdata[i][0] = '#'; } printf("%s\n", graphdata[i]); } printf("End of graph\n"); return 0; } int main() { int max = 50; int arr[] = {12, 32, 40, 30, 20, 50, 10, 30}; char** data = malloc(10 * sizeof(char*)); for (int i = 0; i < 10; i++) { *(data+i) = malloc(12 * sizeof(char)); strcpy(*(data + i), " "); } for (int i = 0; i < 8; i++) { printgraph(max, arr[i], data, '#', "y", "x"); } }