Day 94/100 100 Days of Code

Day 94/100 100 Days of Code

Jumping Ball

More string issues. I made many changes to fix the problem where the variables holding the paths were getting altered. I tried using a mix of calloc, memory addresses of char**, and const, but the result was the same. I still don't know how to fix it.

For the results, I created a for loop to read the values from the CSV file that the mini application outputs. It seems to work well. I might need to add a switch here to assign the correct values to the Results struct. The loop has not been completed yet because I spent most of the session figuring out errors.

for (int i = 0; i < 3; i++)
{
    char *characterLoc = strchr(tempCopy, ',');
    size_t index  = (size_t)(characterLoc - tempCopy);
    char *result = calloc(index, sizeof(char));
    strncpy(result, tempCopy, index);
    printf("Result: %s\n", result);
    free(result);
    char *toCopy = calloc(strlen(tempCopy) - index, sizeof(char));
    strncpy(toCopy, tempCopy + index + 1, strlen(tempCopy )- index);
    printf("Copy: %s\n", toCopy);
    tempCopy = toCopy;
}

I guess more experimentation is needed.