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

  • Home
  • SEARCH
  • 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 593437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:50:44+00:00 2026-05-13T15:50:44+00:00

I have the following homework question: Consider the following declarations and answer the question.

  • 0

I have the following homework question:

Consider the following declarations and answer the question.
char strarr1[10][32];
char *strarr2[10];

Are strarr1[3][4] and strarr2[3][4] both legal references?

I tried compiling the code with gcc to test it. I was fairly sure that the second reference would throw an error, but it didn’t. This is what I compiled with gcc:

int main(void){
    char strarr1[10][32];
    char *strarr2[10];

    char x = strarr1[3][4];
    char y = strarr2[3][4];

    return 0;
}

I’m working under the assumption that the test code I used is correct.

How is it possible to reference strarr2[3][4] when strarr2 is a single-dimensional array?

  • 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-13T15:50:45+00:00Added an answer on May 13, 2026 at 3:50 pm

    since strarr2 is an array of char*, the second [4] is an index into the char*

    it means the same thing as this

    char * temp = strarr2[3];
    char y = temp[4];
    

    Since I don’t see anywhere in your code where strarr2 is being initialized, nor do I see anywhere that strarr2[3] is being allocated, this code will not work as presented. It will either return garbage or segfault.

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

Sidebar

Related Questions

I'm working on my compiler homework and I have the following question: Consider the
I have following text in a file 23456789 When I tried to replace the
I have following Code Block Which I tried to optimize in the Optimized section
I have the following assignment for homework. Requirements Design a class called TokenGiver with
I have in my homework some question about data structure: I have elements which
I have a question about my homework problem. Here is the problem: Write a
I'm stumped by the following homework question for an algorithms class: Suppose that we
So I have the following homework, but I don't understand exactly what the process
This question is on my CS homework and I have no idea how to
I have a homework that asks me to do the following: Design a template

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.