Changed memory handling

This commit is contained in:
garrett 2024-09-19 10:26:09 -04:00
parent 33d9590acb
commit 1c16d83027

View File

@ -4,7 +4,7 @@
void header(int width, int margin, char lineChar, char *headerTitle, char *message);
int main() {
char message[] = "This program will calculate your BMI, Life Expectancy, and BSA(multiple methods) with just your weight(kg), height(cm), and gender.";
char message[] = "Testing this out some more. okay i think its working now DHOWEIFH HDSOIHTOHNDS HSODUIHT. This program will calculate your life expecantacy and bmi and BSA by just your weight(kg), height(cm), and gender.";
printf("%d\n", (int)strlen(message));
header(80, 4, '*', "Purpose", message);
@ -48,6 +48,7 @@ void header(int width, int margin, char lineChar, char *headerTitle, char *messa
if ((contentWidth * rows) > (int)strlen(message)) { break; }
if (message[(contentWidth * rows)] != ' ') {
int i = 1;
int tempCounter = 0;
while (1) {
printf("previous char = %c\n", message[(contentWidth * rows) - i]);
if (message[(contentWidth * rows) - i] == ' ') {
@ -57,18 +58,22 @@ void header(int width, int margin, char lineChar, char *headerTitle, char *messa
printf("start = %d\n", start);
printf("char after start = %c\n", message[start]);
int k = 0;
for (int j = 0; j < (int)strlen(tempMessage); j++) {
for (int j = 0; j < (int)strlen(message); j++) {
tempMessage[j] = ' ';
}
for (int j = start; j < strlen(message); j++) {
tempMessage[k] = message[j];
tempCounter = k;
k++;
}
for (int j = 0; j < i; j++) {
message[start + j] = ' ';
}
for (int j = 0; j < ((int)strlen(message)) - start - 1; j++) {
for (int j = 0; j < tempCounter + 2; j++) {
message[(start + i) + j] = tempMessage[j];
if (tempCounter + 1 == j) {
message[(start + i) + j] = 0;
}
}
break;
}
@ -78,7 +83,7 @@ void header(int width, int margin, char lineChar, char *headerTitle, char *messa
rows++;
}
printf("%s\n", tempMessage);
printf("%c\n", message[230]);
printf("%s\n",message);
printf("%s\n", topLine);
@ -91,7 +96,7 @@ void header(int width, int margin, char lineChar, char *headerTitle, char *messa
}
for (int j = 0; j < contentWidth; j++) {
if (charCount == 0 && (message[j + (i * contentWidth)] == ' ')) {j++;}
if (j + (i * contentWidth) == (int)strlen(message)) {
if (!(message[j + (i * contentWidth)])) {
break;
}
printf("%c", message[j + (i * contentWidth)]);