Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error: expected ':', ',', ';', '}' or '__attribute__' before '=' token

error: expected ':', ',', ';', '}' or '__attribute__' before '=' token

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krish_kumar
    wrote on last edited by
    #1

    After compiling the code given below the following error shows.... main.c:4: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token #include struct struct_keywords { char c_keywords[6][10] = {"int", "char", "static" , /* ERROR SHOWS HERE */ "struct", "union", "return"}; }; typedef struct struct_keywords kewords_t; int main(int argc ,char *argv) { kewords_t *struct_ptr; return 0; } What may be the error ????? With regards

    L C 2 Replies Last reply
    0
    • K krish_kumar

      After compiling the code given below the following error shows.... main.c:4: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token #include struct struct_keywords { char c_keywords[6][10] = {"int", "char", "static" , /* ERROR SHOWS HERE */ "struct", "union", "return"}; }; typedef struct struct_keywords kewords_t; int main(int argc ,char *argv) { kewords_t *struct_ptr; return 0; } What may be the error ????? With regards

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Your initialisers should be outside of the struct definition thus:

      struct struct_keywords
      {
      char c_keywords[6][10];
      } mystruct =
      {
      "int", "char", "static",
      "struct", "union", "return"
      };

      K 1 Reply Last reply
      0
      • K krish_kumar

        After compiling the code given below the following error shows.... main.c:4: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token #include struct struct_keywords { char c_keywords[6][10] = {"int", "char", "static" , /* ERROR SHOWS HERE */ "struct", "union", "return"}; }; typedef struct struct_keywords kewords_t; int main(int argc ,char *argv) { kewords_t *struct_ptr; return 0; } What may be the error ????? With regards

        C Offline
        C Offline
        CODEPC
        wrote on last edited by
        #3

        int main(int argc ,char *argv)
        {

        kewords_t struct_ptr;

        struct_ptr.c_keywords = {"int", "char", "static" , "struct", "union", "return"};

        }

        K L 2 Replies Last reply
        0
        • C CODEPC

          int main(int argc ,char *argv)
          {

          kewords_t struct_ptr;

          struct_ptr.c_keywords = {"int", "char", "static" , "struct", "union", "return"};

          }

          K Offline
          K Offline
          krish_kumar
          wrote on last edited by
          #4

          myprogarm.c: In function 'main': myprogarm.c:17: error: expected expression before '{' token #include struct struct_keywords { char c_keywords[6][10]; }; typedef struct struct_keywords kewords_t; int main(int argc ,char *argv) { kewords_t *struct_ptr; struct_ptr->c_keywords = {"int", "char", "static" , "struct", "union", "return"}; return 0; } :(( Still showing error ...How to clear :(( myprogarm.c: In function 'main': myprogarm.c:17: error: expected expression before '{' token

          1 Reply Last reply
          0
          • L Lost User

            Your initialisers should be outside of the struct definition thus:

            struct struct_keywords
            {
            char c_keywords[6][10];
            } mystruct =
            {
            "int", "char", "static",
            "struct", "union", "return"
            };

            K Offline
            K Offline
            krish_kumar
            wrote on last edited by
            #5

            Thanks ...using ur code I cleared my errors in the program Thanking u :mad::mad::mad:

            L 1 Reply Last reply
            0
            • C CODEPC

              int main(int argc ,char *argv)
              {

              kewords_t struct_ptr;

              struct_ptr.c_keywords = {"int", "char", "static" , "struct", "union", "return"};

              }

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              This is not correct, for a start struct_ptr has not been initialised to point to anything. I always try compiling my code suggestions before posting here.

              1 Reply Last reply
              0
              • K krish_kumar

                Thanks ...using ur code I cleared my errors in the program Thanking u :mad::mad::mad:

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Happy to help.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups