나는 정의 목록의 각 노드와, 구조와 연결리스트 사전을 구축하고있어 다음과 같은 : 내가 키 또는 값에 값을 할당있을 때 내가 문제로 실행 해요C에서 구조체 포인터에 값을 할당하는 데 문제가 있습니까?
typedef struct node node;
struct node
{
int key;
char value[ARRAY_MAX];
node *next;
};
입니다 내 삽입 및 makedict 함수 내에서.
node* insert(node* start, char* vinput, int kinput) {
node* temp = start;
while((temp->next->key < kinput) && temp->next!=NULL) {
temp=temp->next;
}
if(temp->key==kinput) {
temp->key = kinput;
return temp;
} else {
node* inputnode = (node*)malloc(sizeof(node));
inputnode->next = temp->next;
temp->next = inputnode;
inputnode->key = kinput; /*error: incompatible types in assignment*/
inputnode->value = vinput;
return inputnode;
}
과 :
node* makedict(char* vinput, int kinput) {
node* temp = (node*)malloc(sizeof(node));
temp->value = vinput;
temp->key = kinput; /*error: incompatible types in assignment*/
temp->next = NULL;
return temp;
}
나는 아마 믿을 수 없을만큼 분명 뭔가가있어 알아,하지만 난 아무 소용 반복이 코드를 읽어 봤는데 내가 할당에서 다음과 같은 오류를 받았다. 어떤 도움을 주셔서 감사합니다.
을,'경우 (temp-> 키 == kinput)'왜이다 'temp-> key = kinput;'을 다시 할당합니까? : \ –
아, 맞습니다. 약간의 중복 된 코드! 반복되는 주요 입력을 저장하려는 포기한 시도에서 내가 거기에 놓아 두었을 수도 있습니다. 좋은 픽업 :) – user2741466