Home c Error "Error: Assignment to Expression with Array Type"

Error “Error: Assignment to Expression with Array Type”

Author

Date

Category

I want to draw a game field. Created 2D Massa, and wanted to transfer some data in its cells. As a result, it gives an error “Error: Assignment to Expression with Array Type”. How can I do it? thanks
Code:

# include & lt; stdio.h & gt;
#Include & lt; stdlib.h & gt;
#Include & lt; String.h & gt;
#Include & lt; conio.h & gt;
#Include & lt; stdbool.h & gt;
Void draw_field () {
  // Const int width = 20;
  // Const int height = 20;
  CHAR FIELD [20] [20];
  field [0] = "####################";
  field [19] = "####################";
  PrintF ("% s \ n", field [0]);
  for (int i = 1; i & lt; 19; i ++) {
    field [i] = "# #";
    PrintF ("% s \ n", field [i]);
  }
  PrintF ("% s \ n", field [0]);
}
INT MAIN ()
{
  Const Bool Gameover = false;
  draw_field ();
  Return 0;
}

Errors:

main.c: in function 'draw_field':
Main.c: 19: 14: Error: Assignment to Expression with Array Type
   field [0] = "####################";
       ^
Main.c: 20: 15: Error: Assignment to Expression with Array Type
   field [19] = "####################";
        ^
Main.c: 23: 18: Error: Assignment to Expression with Array Type
     field [i] = "# #";
         ^

Answer 1, Authority 100%

These are arrays!

strcpy (field [0], ################ ####);

Behind the highlight of a sufficient place, follow yourself.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions