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 8425009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:09:34+00:00 2026-06-10T04:09:34+00:00

Hi I was unable to find the cause of the compilation error while trying

  • 0

Hi I was unable to find the cause of the compilation error while trying this code on Visual studio 2008. I was trying to see an example of char* return value by a function .

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char* getActiveModuleType(void);
void main()
{
char getActiveModuleBuff[128];
//error C2106: '=' : left operand must be l-value
getActiveModuleBuff = getActiveModuleType();
printf("Active module in well formatted (2): %s\n",getActiveModuleBuff);

    exit(0);
 }
 char* getActiveModuleType(void)
 {
char activeModule[128];
int tempBuffLen=0;
int nbActivemodule = 0;
char moduleA        = 1;
char moduleB        = 1;
char moduleC        = 0;
char moduleD        = 1;
int i = 0;
if(moduleA==1) {activeModule[i] ='A'; activeModule[i+1]=','; i= i+2;}
if(moduleB==1) {activeModule[i] ='B'; activeModule[i+1]=','; i= i+2;}
if(moduleC==1) {activeModule[i] ='C'; activeModule[i+1]=','; i= i+2;}
if(moduleD==1) {activeModule[i] ='D'; activeModule[i+1]=','; i= i+2;}

printf(" Active module in : %s\n",activeModule);
//let get get the last ',' value trucated
tempBuffLen = strlen(activeModule);
nbActivemodule = tempBuffLen/2;
if((tempBuffLen == 0) && (nbActivemodule ==0)){
        memcpy(activeModule,"NoActiveModule",14);
        return activeModule;
}
if(activeModule[tempBuffLen-1]==',')
    activeModule[tempBuffLen-1] = '\0';
printf(" Active module in well formatted : %s\n",activeModule);

return activeModule;
}

i am unable to find why this Error C2106 occurs in this code .
Help required.
thanks

  • 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-06-10T04:09:35+00:00Added an answer on June 10, 2026 at 4:09 am
    char getActiveModuleBuff[128];
    getActiveModuleBuff = getActiveModuleType();
    

    You cannot assign a value to an array in C.

    Use memcpy to copy an array or strcpy / strncpy to copy a string.

    Also in:

     char* getActiveModuleType(void)
     {
         char activeModule[128];
         /* ... */
         return activeModule;
     }
    

    the activeModule array object is destroyed at the end of the function. Accessing it after the function returns is undefined behavior.

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

Sidebar

Related Questions

I have been unable to find any decent documentation on this function. The code
I've been unable to find any info on this, which seems like it could
I am sure this will have been answered but I proved unable to find
I am trying to locate IOS SDK 4.0. But I'm unable to find it.
I am trying to programmatically add the following Target to my Visual Studio Project
I'm trying to write to a JDO store using this code: PersistenceManager pm =
I was unable to find this on php.net. Is the double equal sign (
I am unable to find out more about this default parameter that I ran
I've been unable to find an adequate solution to this problem, so any help
I have been unable to find any documentation on the .build method in Rails

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.