Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

warning C4047: '=' : 'char' differs in levels of indirection from 'char *'

Tags:

c

visual-c++

c99

What is the problem with the code shown below.

char filter[2] = {'\0'};
*filter = (char *)calloc((unsigned int)buf.st_size + 1, sizeof(unsigned char));

As per my understanding, there is no problem changing the array location right? Why I ask this is because of a warning,

Warning 1   warning C4047: '=' : 'char' differs in levels of indirection from 'char *'

Any idea?

Got it, changed the code to. Thanks @ouah

char *filter = {'\0'};
filter = (char *)calloc((unsigned int)buf.st_size + 1, sizeof(unsigned char));
like image 544
Jimson James Avatar asked Mar 31 '13 15:03

Jimson James


1 Answers

*filter is a char and you are assigning it a char * value.

like image 100
ouah Avatar answered Nov 17 '22 12:11

ouah