I'm new in c/c++ and confused because of char array (char[]) initializing
below is my code.
#include <iostream>
using namespace std;
struct Node {
char key[5];
int value;
Node* next;
};
Node* tb[10]; // 해시 테이블(해당 인덱스에 리스트로 작성)
char* keys[5]; // 키는 중복 비교를 위해 따로 저장
void m_strcpy(char dsc[], char src[]) {
while (*src != '\0')
*(dsc++) = *(src++);
}
int main() {
Node* newNode = new Node;
char key[4] = "1";
newNode->key = "1";
return 0;
}
first
char key[4] = "1";
is ok. but below code gives me "expression must be a modifiable lvalue error".
newNode->key = "1";
well newNode->key is char key[5]. and is same as char key[4] i think. but why the difference happens?
thanks for reading my question.