I have a little software program, where I do an API call to retrieve the name of a device that's assigned on a server. Every once in a while though, a glitch occurs and it fetches a semi-random series of characters and numbers. Ideally, I'd want to tackle the source of this problem, but as of date I haven't found any information on why this glitch may occassionally be happening. Therefore, I simply want to instruct the device to re-do the API call to fix this issue.
The variable is defined as char deviceName[64]. When it glitches out, the name it fetches always starts with the word talwrite. The easiest solution IMO would be to set up an if-statement, and if the fetched name includes the word talwrite, it'll re-do the API call.
std::string temp(deviceName); // create a std string
if (temp.find("talwrite") == 0) // if "talwrite" begins at location 0 of string i.e. at start of string
{
// redo API call
}