c - Expression must be a pointer to a complete object type when cast void pointer -
i'm trying function remove extension of name type wchar_t or char, inside for() cast void pointer type wchar_t or char, there error:
expression must pointer complete object type.
here sample code show instance of issue itself.
int removeextension( void *p_str, /* name */ bool iswchar /* true:wchar_t, false:char */ ) { int ii, len; // length len = (iswchar) ? wcslen( (wchar_t *)p_str ) : strlen( (char *)p_str ); // remove extension /* wchar_t */ if( iswchar ) { for( ii = 0; ii < len; ii++ ) { if( l'.' == (wchar_t *)p_str[ii] ) { //error here (wchar_t *)p_str[ii] = l'\0'; //error here break; } } } /* char */ else { for( ii = 0; ii < len; ii++ ) { if( '.' == (char *)p_str[ii]) { //error here (char *)p_str[ii] = '\0'; //error here break; } } } return 0; }
i'm not understanding error trying say. there no object or struct here.
i dont know why error, according this table expression
(wchar_t *)p_str[ii]
(wchar_t *)(p_str[ii])
not ((wchar_t *)p_str)[ii]
,
probably it's not want
Comments
Post a Comment