c - char array in switch statement with strange error message -


I have a question I have declared a letter as an array and based on any other parameter, this array Has to look different.

  Four maps [10] [10]; Switch (Stage) {Case 1: // map NR1 map [10] [10] = {{'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '', '', '', '', '', '', '', '', '#'}, {'#', '', '', '', '', '', '', '', '', '#'}, {'', '', '', '', '', '', '#' ,' ',' ',' # '}, {' # ',' ',' # ',' ',' And ',' ',' # ',' ',' ', '#', '' , '#', '#', '', '', '', '#', '', '', '#'}, {'#', '', '#', '#', '# ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' ' ','#'}, {'#','Phase 1',' ',' ',' # '}, {' # ',' # ',' # ',' # ',' # ', '#', '#', '#', '#', '#'}}; break; Case 2: // map NR2 map [10] [10] = {{'#', '#', '#', '#', '#', '#', '#', '#', ' # ',' ',' ',' ',' ',' ',' ',' # ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' '', '', '', '', '', '', '', '', '', '', '#', '', '', '', '#', '', '', '' , '', '', '#'}, {'#', '', 'And', '', '', '', '#', '', '', '#'}, { ' # '', '', '#', '', '', '', '#', '', '', '#', '', '', '#', '#', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', , '', ' ' ','#'}, {'#','Phase 2',' ',' ','#'}, {' # ',' # ',' # ',' # ' , '#', '#', '#', '#', '#', '#'},}; break; }   

Now my question is: Why do I get this ?: main.c: 'map_initialisation' in function: main.c: 32: 15: Error: Expected expression before '{' token map] [10] [10] = {^ main.c: 46: 15: Error: Expected expression before '{' token map] [10] [10] = {^ / Code>

What is wrong with this code excerpt

You only use special You can do the initial syntax when you first declare the map, not later. Try to do something like this:

  Four Maps 1 [10] [10] = {{'#', '#', '#', '#', '#', ' # ',' # ',' # ',' # ',' # ',' # '},' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' # ',', '', '', '', '', '', '#', '', '', '', '', '', '', '', '', '', , '', '#', '', '', '#'}, '' '' '', '', '#', '', 'And', '', '#', '' , '', '#', '', '', '#', '', '', '', '#', '', '', '#'}, {'#', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' ' ',' ',' ',' ','#'}, {'#','Phase 1',' ', '', '#', {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#'}}; Four maps [2], "#"}, "", "", "", "", "", "#"}, {'#', '', '', '', '', '' , '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', , '#', '', '' , '#', '' '', '', 'And', '', '', '', '#', '', '', '#'} , '', '', '', '', '', '#', '', '', '#', '', '', '', '', '#', '', '', '', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' ',' ',' ',' # ' }, {'#','Phase 2',' ',' ','#'}, {'#','#' , '#', '#' , '#', '#', '#', '#', '#', '#'},}; Four (* current_level) [10]; Switch (Stage) {Case 1: Current_Livol = Map 1; break; Case 2: Current_Livol = Map2; break; }   

Edit: Fixed a typical problem

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -