I have some code: I'm trying to compare xID with a string version of the ID. I want to convert xID to string, so I decided to try to use sprintf and I'm really running into a lot of issues. I have tried using snprinft and asprintf and it doesnt work. * cant find library
how can i make this integer a string with 8 digits and leading 0s? if theres something im doing wrong with sprintf, please let me know. ive been looking at this trying to read stuff for over an hour and am so lost
bool LinkedList::checkID(Node* head, int xID){
Node* ptr = head;
char stringID[8]; // changed to 36
sprintf (stringID, "%08d \n", xID);
cout << stringID << endl; // flushed cout and changed formatting
while (ptr != NULL){
if (strcmp(ptr->student.ID, stringID) == 0){
return false;
}
ptr = ptr->next;
}
return true;
}