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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:43:42+00:00 2026-06-08T08:43:42+00:00

I have 2 language codes coming in the stream. I’m storing this in a

  • 0

I have 2 language codes coming in the stream. I’m storing this in a 3 byte char array(unsigned char a[3]). I wanted to compare it with another value stored in a pointer(unsigned char *c).The array a[3] is stored inside a structure(struct s[2]) to get the multiple datas – Is this correct as i’m little confused as array – const pointer cannot be made to point to another location as it is already pointing to a location. But including the array inside a structure and making the zeorth element of the structures array to point to one location and the 1 st element of the structures array is possible. Is the understanding i have is correct.

I wanted to store the 2 array values.So I have declared a structure inside which i have declared the 3 byte char array.Is this way of doing is correct. Is there alternate way to do it.

EDITED:

   #include<stdio.h>
int main(){
 int i,flag=0,count=0;
 struct n{
  unsigned char b[3];
 };
 unsigned char *d=NULL; 
 struct s{
  unsigned char *a;
 };
 struct s m[2];
 struct n w[2];
// memcpy(w[0].b,"eng",sizeof("eng"));
// memcpy(w[1].b,"fre",sizeof("fre"));
strcpy(w[0].b,"eng");
strcpy(w[1].b,"fre");

 d = w[1].b; // current lang
 m[0].a = w[0].b; // storing the 2 lang in a pointer inside a structure
 m[1].a = w[1].b;
 i=0;
 printf("\nm[0].a:%s\n",m[0].a);
 printf("\nm[1].a:%s\n",m[1].a);
printf("\nw[0].b:%s\n",w[0].b);
 printf("\nw[1].b:%s\n",w[1].b);
 while((m[i].a) && d){ // And comparing
  if(m[i].a++ != d++){ 
   flag =1; //if strings are unequal break;
   break;
  }
 i++;
 }
  if(flag){
   printf("Not equal\n");
  }
  else{
   printf("\nEqual\n");
   flag =0;
  }
 return 0;
}

o/p:

m[0].a:engfre

m[1].a:fre

w[0].b:engfre

w[1].b:fre
Not equal

But there s an mistake it shows un equal . Is this way of storing the arrays in a pointer inside a strucutre is correct method. or is there any other way to do this.

EDIT:

I wanted to compare the 2 strings. The 2 strings are equal but i’m getting it as unequal.
Is the pointer a need to be stored in a structure to store the 2 arrays or is there another way of dong this.

  • 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-08T08:43:44+00:00Added an answer on June 8, 2026 at 8:43 am
    #include <stdio.h>
    #include <string.h>
    int main(){
      int i,flag=0,count=0;
      struct n{
        unsigned char b[4];
      };
      struct s{
        unsigned char *a;
      };
      unsigned char *d=NULL; 
      struct s m[2];
      struct n w[2];
      strcpy(w[0].b,"eng");
      strcpy(w[1].b,"fre");
      d = w[1].b; // current lang
      m[0].a = w[0].b; // storing the 2 lang in a pointer inside a structure
      m[1].a = w[1].b;
      for (i =0; i <= 1; i++) {
        printf("\nm[%d].a: %s d: %s\n", i, m[i].a, d);
        if (strcmp(m[i].a, d) != 0) {
          printf("Not equal\n");
        }
        else{
          printf("\nEqual\n");
        }
      }
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written grammar for a language (sample code below) //this is a procedure
I have a cross-language problem regarding md5 :). I have this code in Java:
I'm makin' a scripting language interpreter using PHP. I have this code in that
I have this HTML table: <table id=languages border=0 cellspacing=1> <thead> <tr> <th>Language</th> <th>Type</th> <th>Invented</th>
I am relatively new to Haskell, coming from F# (a Microsoft language). I have
I am writing some Natural Language Processing code and want to have a binary
I have code that relies heavily on yaml for cross-language serialization and while working
I have some code that sets the lang var to the site default language.
In my application there is language detection. Languages have some identification code like en
I'm currently learning the C programming language (coming from Java) and I'm a bit

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.