Actually I have change the plan for this process. And now i am trying to generate a string that will increment as above C0001, C0002, C0003... every time it does a loop.
This is the code i have at the moment but for some reason the output is not correct.
Code:
void addCategory(GJCType* menu) {
char newCatID[ID_LEN + 1] = {0};
char catID[ID_LEN + 1] = {"C"};
char* catIDPtr = catID;
char temp[menu->numCategories][ID_LEN + 1];
int index = 0;
char* newCatIDPtr = newCatID;
CategoryType* current = menu->headCategory;
while (current != NULL) {
index++;
current = current->nextCategory;
sprintf(newCatID, "%04i", atoi(newCatID) + index);
strncat(catIDPtr, newCatID, ID_LEN);
printf("%s\n", catIDPtr);
strncpy (catID, "C\0", ID_LEN + 1);
}
}
OP
C0001
C0003
C0006
C0010
C0015
C0021
C0028