Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This is what I have now.

void insert(char Table[][81], char Key[81]){
    int index;
    index = search(Table, Key); 
    // This is another function used to find an empty 'slot'
    // in the table
    if(Table[index] == '')
    Table[index] = Key; 
    // <-- This is the line that contains some sort of error.
    else
    printf("ERROR: Key already in Table
");
}

The error it is throwing is:

incompatible types when assigning to type 'char[81]' from type 'char *'.

I am at a loss as to how to fix or why this error is being thrown. If anyone needs more info from my program to draw a conclusion please let me know.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
987 views
Welcome To Ask or Share your Answers For Others

1 Answer

You cannot assign arrays but you can use strcpy() or memcpy() instead:

if (Table[index][0] == '')
    memcpy(Table[index], Key, sizeof(Key));
else
    printf("ERROR: Key already in Table
");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...