Question: In the following code, write the single word variable / value / function in the blanks provided below (words are case sensitive) Function getFieldValStartIdx returns
In the following code, write the single word variable / value / function in the blanks provided below (words are case sensitive) Function getFieldValStartIdx returns the index/ position of the start of a field value in a comma delimited c-string (a_textInfo). Entries are separated by commas Each entry is of the form field_name:field_value. The function returns the index of the first character in field_value. Example: If a_textInfo is "Cat Name: Mr. Whiskers, Age: 4, Weight: 10.000" a_fieldName is the field name, which could be "Cat Name", "Age" or "Weight" in this example. The corresponding field values are "Mr. Whiskers", " 4", and " 10.000" If a_fieldName is "Age", the start index is position of space between ':' and 4 (red underline) If a_fieldName is "Weight" then return index of space between : and 10.000 int getFieldValStartIdx(const char* a_textInfo, const char* a_fieldName) { const char* p_fieldStart = strstr(a_textInfo, BLANK 1 ); if (p_fieldStart != BLANK 2 ) { const char* p_endPtr = strchr( BLANK 3 , ':'); assert(p_endPtr != NULL); return p_endPtr - BLANK 4 + 1; } return -1; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
