Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6774429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:47:09+00:00 2026-05-26T15:47:09+00:00

I am writing a code where I have to add a value to an

  • 0

I am writing a code where I have to add a value to an abstract data table, but I am not sure why I cannot as it shows “error C2106: ‘=’ : left operand must be l-value” error.

int top_add(top_string *table, const char index[257], const char other[257]) {

    top_remove(&table, index);

    if (table->item_count == table->size) {
        printf("/n Table is full.");
        return -1;
    }

    /* error C2106: '=' : left operand must be l-value */
    table->item[table->item_count].index = index; 

    /*error C2106: '=' : left operand must be l-value */
    table->item[table->item_count].other = other;

    table->item_count++;

    return 1;
}

I did some search online, but could not find too relative solution for me.

I would really appreciate any hint on that.

UPDATE:

typedef struct {
    char index[257];
    char other[257];
} pair;


typedef struct {
    pair *item;
    int item_count;
    int size;
} top_string;

int top_init(top_string *table, const int size) {

    table->item = malloc((size+1)*sizeof(top_string));
    table->size = size;
    table->item_count = 0;

    if (table->item == NULL) {
        return 0; /* failed to allocate memory */
    } else {
        return 1;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:47:10+00:00Added an answer on May 26, 2026 at 3:47 pm

    The fields index and other are arrays, you can’t assign arrays. You’d have to copy them with memcpy.

    Another option would to have top_add receive pair instead of the two separately. Then you could assign the struct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a year's experience writing client code but none with server stuff. I
I have been writing some code that detects add and removal of USB devices,
I'm not sure if this is the most optimal way of writing this code,
I have just installed C# 2008 Express Edition 2008 and started writing code. My
I am writing code in VS2005 using its STL. I have one UI thread
I am writing code to performance test a web site. I have the following
I have a programming experience with statically typed languages. Now writing code in Python
I have been writing Python code for only a couple of weeks, so I'm
Does anyone have some good hints for writing test code for database-backend development where
I have always made a point of writing nice code comments for classes and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.