Error C3861, Passing string to function
Mar 21, 2014 at 3:04pm UTC
I've tried to debug this, watched several youTube videos on the subject, but I still am stumped by why this code is failing me.
I've bolded the actual line that is generating the error
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
void getUserColor(char UserColorTable[NUMBER_OF_BANDS][MAX_CHARATER_COUNT], char ComputerColorTable[NUMBER_OF_COLORS][MAX_CHARATER_COUNT], double colorNumberArray[NUMBER_OF_BANDS], int rowOfUserTable)
{
int errorValue = 0;
char userInput[MAX_CHARATER_COUNT];
char extractString[MAX_CHARATER_COUNT];
printf("Please tell me the color of band %d: " , rowOfUserTable + 1);
gets_s(userInput);
for (int i = 0; i < NUMBER_OF_COLORS; i++)
{
extractAString(extractString, ComputerColorTable, i);
if (0 == strcmp(userInput, extractString))
{
colorNumberArray[rowOfUserTable] = (double )i;
i = NUMBER_OF_COLORS - 1;
errorValue++;
}
}
if (errorValue == 0)
{
printInputError(userInput);
}
}
void extractAString(char extract[MAX_CHARATER_COUNT], char source[NUMBER_OF_COLORS][MAX_CHARATER_COUNT], int rowNumber)
{
for (int i = 0; i < MAX_CHARATER_COUNT; i++)
{
extract[i] = source[rowNumber][i];
}
}
Mar 21, 2014 at 3:36pm UTC
Has the function been declared before you call it?
Mar 21, 2014 at 3:39pm UTC
To add to what Peter87 wrote, pre-declarations are case sensitive so double check your spelling or just copy the function name and paste over it.
Mar 21, 2014 at 3:53pm UTC
Also this function have same semantic as srtncpy(extractString, ComputerColorTable[i], MAX_CHARATER_COUNT)
Apr 5, 2014 at 11:07am UTC
as it results, it was an issue that the header and the prototype were not in synch when I complied it. Fixed that and it ran just fine. Thanks for the tips, I'd never caught that without your help.
Topic archived. No new replies allowed.