我正在尝试将char*字段分配给char*字段,但是会收到此错误:
incompatible types when assigning to type 'char[128]' from type 'char *'
我怎样才能解决这个问题?为什么会这样?
AddressItem_Callback_ContextType *context = (AddressItem_Callback_ContextType *)malloc(sizeof(AddressItem_Callback_ContextType));
//check if icons need to be downloaded
if (pEntity->cBigIcon[0] != 0){
if (res_get(RES_BITMAP,RES_SKIN, pEntity->cBigIcon) == NULL){
context->Icon = pEntity->cBigIcon;
context->iID = pEntity->iID;
res_download(RES_DOWNLOAD_IMAGE, pEntity->cBigIcon, NULL, "",TRUE, 1, addressItem_icon_download_callback, context );
}
}
Run Code Online (Sandbox Code Playgroud)
声明:
typedef struct
{
int iID; // POI Type ID
int iExternalPoiServiceID; // Service ID
int iExternalPoiProviderID; // Provider ID
char cBigIcon[MAX_ICON_LENGHT];
char cSmallIcon[MAX_ICON_LENGHT];
char cBigPromotionIcon[MAX_ICON_LENGHT];
char cSmallPromotionIcon[MAX_ICON_LENGHT];
char cOnClickUrl[MAX_URL_LENGTH]; …Run Code Online (Sandbox Code Playgroud) 我的结构如下:
typedef struct {
unsigned long attr;
char fileName[128];
} entity;
Run Code Online (Sandbox Code Playgroud)
然后我尝试分配一些值,但得到一条错误信息......
int attribute = 100;
char* fileNameDir = "blabla....etc";
entity* aEntity;
aEntity->attr = attributes;
aEntity->fileName = fileNameDir;
Run Code Online (Sandbox Code Playgroud)
编译告诉我:
错误:#137:表达式必须是可修改的左值aEntity-> fileName = fileNameDir;
为什么我不能在这里将这个角色分配给结构中的那个角色?
谢谢