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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:16:31+00:00 2026-05-23T15:16:31+00:00

I am trying to manipulate the elements in a 2D array #include <stdio.h> main()

  • 0

I am trying to manipulate the elements in a 2D array

#include <stdio.h>

main()
{
    char arr[][30] = {"hello", "goodbye"};
    printf("%s\t%s\n",arr[0], arr[1]);
    arr[0] = arr[1];
    printf("%s\t%s\n",arr[0], arr[1]);
}

incompatible types when assigning to type ‘char[30]’ from type ‘char *’

I am new to C and coming from an OO background, so my knowledge of pointers is still very fundamental.

I understand this can be done using an array of pointers, but would like to know how to perform this operation with 2D arrays

Thank you for any clarification

  • 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-23T15:16:31+00:00Added an answer on May 23, 2026 at 3:16 pm

    You need char* arr[] instead, since you can’t assign an array to another array.

    But whyyyyy?

    Well, what would that mean? Should it copy over the elements? Use strncpy or memcpy for that. Or should it somehow "redirect" the previous array? That doesn’t make sense, because an array is just a block of memory… what can you do with it, other than modify its contents? Not much! You can, however, have a pointer to the block, and change it to point somewhere else instead.

    But aren’t arrays and pointers the same thing?

    No!! Why would they have two different names, then? 😛 Arrays can decay to pointers implicitly (the address of their first elements), but they’re not the same thing! Pointers are just addresses, whereas arrays are a block of data. They have no relation to each other, other than the implicit conversion. 🙂

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

Sidebar

Related Questions

I'm trying to manipulate two elements within a jquery function and i'm not seeing
I'm trying to manipulate the XUL elements in the Firefox add-on page using the
You see I'm trying to manipulate some elements when comparing their index. The problem
I am trying to manipulate a string using Jython, I have included below an
I am currently trying to manipulate a unordered list with jQuery, essentially I have
I am trying to manipulate a conditional string outputted from SAS into the right
It strikes me that Properties in C# should be use when trying to manipulate
I'm looking for a good python library to manipulate subversion repositories. I'm trying out
Trying to make a make generic select control that I can dynamically add elements
I'm getting the weirdest issues with Javascript in Firefox today. I'm trying to manipulate

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.