#include <stdio.h>
#include <stdlib.h>
char *color[] =
{
/*0*/"red||bluegreen",
/*1*/"blue",
/*2*/"green",
"\0"
};
int fun1(char * str1)
{
int c = 0;
while(1)
{
if(str1[c] == '|' && str1[c+1] == '|')
return c;
c++;
}
return 0;
}
1. int main()
2. {
3. int ret=0, offset=0;
4. ret = fun1(color[offset]);
5 offset += ret;
6 ret = fun1(color[offset]);
7 return 0;
}
In the above code snippet in main()
at line 6 the argument to fun1()
is color[offset] = NULL
Why is color[offset] = NULL
after the operation offset += ret
. Please clarify
Thanks