This part of my code:
char MAC_ADRESSES[MAX_LINES][100];
for(j=i+1; j<=countlines; j++)
{
if((MAC_ADRESSES[j])==(MAC_ADRESSES[i]))
{
MAC_ADRESSES[j] = NULL;
}
At the point where I want to change the string with a NULL I have a compiler error about incompatible types assignment. Do not understand why..
Presumably MAC_ADRESSES
is not an array of pointers. NULL
is a pointer (normally (void *)0
in C), so you can't assign it to a non-pointer variable.
Edit: Since your definition is char MAC_ADRESSES[MAX_LINES][100]
, you have a 2D array, not an array of pointers. You can't store NULL
in this array. You can wipe out a string by putting a null character in the first byte, though:
MAC_ADRESSES[j][0] = '\0';
Note that you can't test strings for equality using ==
, either. You should be using strcmp
.