What benefit does it have to have the keyword const
on the function below.
BOOL8 CheckSimilarity(const Name_t NameOne, const Name_t NameTwo)
- Would it affect function in any way if we didn't put keyword const?
I always thought that you will have to pass pointers for variables and compare with pointers in the function so it goes to memory location where the variable is stored and compares the variables themselves as in swap function as in K&R?
typedef UINT8 Name_t[5]
Log_t* Log(Name_t Name)
{
Log_t *point2Log = Log1;
while (point2Log < Log1)
{
if (CheckSimilarity(Name, point2Log->Name))
{
return point2Log;
}
point2Log++;
}
return NULL;
}
BOOL8 CheckSimilarity(const Name_t NameOne, const Name_t NameTwo)
{
UINT8 count;
for (count=0; count<5; count++)
{
if (NameOne[count] != NameTwo[count])
{
return FALSE;
}
}
return TRUE;
}