ok i think i missed the memo

This is a discussion on ok i think i missed the memo within the C Programming forums, part of the General Programming Boards category; ok when i compile my program i get errors like call to function 'printf' with no prototype in function main ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    21

    ok i think i missed the memo

    ok when i compile my program i get errors like call to

    function 'printf' with no prototype in function main

    but i

    #include <stdio.h>

    so im lost plez help

    ~kl3pt0~

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    post code.

    whats OS, what Compiler.

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    ok the os is windows and
    the compilers is C++BUILDER COMMAND LINE

    i know my cide has alot of mess ups in it but im slowly working them out


    Code:
    #include <stdio.h>
    #include <string.h>
    
    
    
    
    
    char *food_name[12] =
    {
      "", "monomate", "dimate", "trimate", "monofluid", "difluid", "trifluid",
        "antidote", "antipyralysis", "sol atomizer", "moon atomizer",
        "star atomizer"
    };
    char *class_name[3] =
    {
      "hunter", "ranger", "force"
    };
    char *statnum[6] =
    {
      "SYNC", "IQ  ", "DEF ", "POW ", "DEX ", "MIND"
    };
    char *section_id[10] =
    {
      "viridia", "greenil", "skyly", "bluefull", "purplenum", "pinkal", "redria",
        "oran", "yellowboze", "whitill"
    };
    int ID;
    int class ;
    char name;
    
    int error_flag = 0;
    int feed_flag = 1;
    char food;
    int exit_flag = 0;
    
    
    char feed_chart[5][11][6] =
    {
        {
            {
                3, 3, 5, 40, 5, 0
            } ,
            {
                3, 3, 10, 45, 5, 0
            }
            ,
            {
                4, 4, 15, 50, 10, 0
            }
            ,
            {
                3, 3, 5, 0, 5, 40
            }
            ,
            {
                3, 3, 10, 0, 5, 45
            }
            ,
            {
                4, 4, 15, 0, 10, 50
            }
            ,
            {
                3, 3, 5, 10, 40, 0
            }
            ,
            {
                3, 3, 5, 0, 44, 10
            }
            ,
            {
                4, 1, 15, 30, 15, 25
            }
            ,
            {
                4, 1, 15, 25, 15, 30
            }
            ,
            {
                6, 5, 25, 25, 25, 25
            }
        }
        ,
    
        {
            {
                0, 0, 5, 10, 0,  - 1
            }
            ,
            {
                2, 1, 6, 15, 3,  - 3
            }
            ,
            {
                3, 2, 12, 21, 4,  - 7
            }
            ,
            {
                0, 0, 5, 0, 0, 8
            }
            ,
            {
                2, 1, 7, 0, 3, 13
            }
            ,
            {
                3, 2, 7,  - 7, 6, 19
            }
            ,
            {
                0, 1, 0, 5, 15, 0
            }
            ,
            {
                2, 0,  - 1, 0, 14, 5
            }
            ,
            {
                 - 2, 2, 10, 11, 8, 0
            }
            ,
            {
                3,  - 2, 9, 0, 9, 11
            }
            ,
            {
                4, 3, 14, 9, 18, 11
            }
        }
        ,
    
        {
            {
                0,  - 1, 1, 9, 0,  - 5
            }
            ,
            {
                3, 0, 1, 13, 0,  - 10
            }
            ,
            {
                4, 1, 8, 16, 2,  - 15
            }
            ,
            {
                0,  - 1, 0,  - 5, 0, 9
            }
            ,
            {
                3, 0, 4,  - 10, 0, 13
            }
            ,
            {
                3, 2, 6,  - 15, 5, 17
            }
            ,
            {
                 - 1, 1,  - 5, 4, 12,  - 5
            }
            ,
            {
                0, 0,  - 5,  - 6, 11, 4
            }
            ,
            {
                4,  - 2, 0, 11, 3,  - 5
            }
            ,
            {
                 - 1, 1, 4,  - 5, 0, 11
            }
            ,
            {
                4, 2, 7, 8, 6, 9
            }
        }
        ,
    
        {
            {
                0,  - 1, 0, 3, 0, 0
            }
            ,
            {
                2, 0, 5, 7, 0,  - 5
            }
            ,
            {
                3, 1, 4, 14, 6,  - 10
            }
            ,
            {
                0, 0, 0, 0, 0, 4
            }
            ,
            {
                0, 1, 4,  - 5, 0, 8
            }
            ,
            {
                2, 2, 4,  - 10, 3, 15
            }
            ,
            {
                 - 3, 3, 0, 0, 7, 0
            }
            ,
            {
                3, 0,  - 4,  - 5, 20,  - 5
            }
            ,
            {
                3,  - 2,  - 10, 9, 6, 9
            }
            ,
            {
                 - 2, 2, 8, 5,  - 8, 7
            }
            ,
            {
                3, 2, 7, 7, 7, 7
            }
        }
        ,
    
        {
            {
                2,  - 1,  - 5, 9,  - 5, 0
            }
            ,
            {
                2, 0, 0, 11, 0,  - 10
            }
            ,
            {
                0, 1, 4, 14, 0,  - 15
            }
            ,
            {
                2,  - 1,  - 5, 0,  - 6, 10
            }
            ,
            {
                2, 0, 0,  - 10, 0, 11
            }
            ,
            {
                0, 1, 4,  - 15, 0, 15
            }
            ,
            {
                2,  - 1,  - 5,  - 5, 16,  - 5
            }
            ,
            {
                 - 2, 3, 7,  - 3, 0,  - 3
            }
            ,
            {
                4,  - 2, 5, 21,  - 5,  - 20
            }
            ,
            {
                3, 0,  - 5,  - 20, 5, 21
            }
            ,
            {
                3, 2, 4, 6, 8, 5
            }
        }
    };
    
    int I;
    int IDtype;
    int PB_ = 1; /*	 initialize PB	   */
    int type = 1; /*   initialize TYPE	*/
    int level = 5; /*	initialize LEVEL */
    int blah;
    int qwe = 0;
    int poke = 1;
    int comm;
    
    
    main()
    {
      new_mag: int stat[6][2];
      //get you section ID
      printf("Enter section ID \n");
      for (qwe; qwe < 10; qwe++)
      {
        printf("%i : %s\n", qwe, section_id[qwe]);
      }
      printf("Enter section ID \n");
      for (qwe = 0; qwe < 10; qwe++)
      {
        printf("%i : %s\n", qwe, section_id[qwe]);
      }
      scanf("%i", &ID);
      for (qwe = 0; qwe < 10; qwe++)
        if (qwe == ID)
          blah = 1;
      if (blah == 0)
        return ;
    
      printf("Enter character class \n");
      for (qwe = 1; qwe < 4; qwe++)
      {
        printf("%i :	%s\n", qwe, class_name[qwe - 1]);
      }
      scanf("%i", &class );
      blah = 0;
      for (qwe = 0; qwe < 4; qwe++)
        if (qwe == class )
          blah = 1;
      if (blah == 0)
        return ;
      class --;
    
      for (qwe = 0; qwe < 9; qwe = qwe + 2)
      {
          if (ID == qwe)
          {
              blah = 0;
          }
      }
      if (blah == 0)
        IDtype = 1;
      else
        IDtype = 2;
    
      printf("your id type is %i \n", IDtype);
      printf("your section id is %s \n", section_id[ID]);
      printf("your class is %s \n", class_name[class ]);
    
    
      for (qwe = 0; qwe < 6; qwe++)
        printf("%s is %i . %i \n", statnum[qwe], stat[qwe][0], stat[qwe][1]);
    
      name = ("mag");
      menue: printf("Enter command: \n");
      printf("1: feed \n");
      printf("2: new \n");
      printf("3: exit \n");
      scanf("%i", &comm);
      switch (comm)
      {
          case 1:
            do
            {
                  if (error_flag == 0)
                  {
                        printf("feed what?:\n");
                        if (feed_flag == 1)
                        {
                              for (qwe = 1; qwe < 12; qwe++)
                              {
                                    printf("%i : %s\n", qwe, food_name[qwe]);
                              }
    
                              printf("12 : to hide food chart \n");
                        }
                        else
                        {
                              printf("12 : to show food chart \n");
                        }
                  }
                  else
                  {
                        printf("Re-input: \n");
                  }
                  printf("13 : for menu \n");
                  error_flag = 0;
                  scanf("%i", &food);
                  if (food > 13)
                    return ;
                  switch (food)
                  {
                      case 12:
                        if (feed_flag == 0)
                          feed_flag = 1;
                        else
                          feed_flag = 0;
                        break;
                      case 13:
                        exit_flag = 1;
                        goto menue;
                        default: printf("the item you picked is %s\n",
                          food_name[food]);
    
                        printf("\n the stat effects are\n\n");
                        for (qwe = 0; qwe < 6; qwe++)
                        {
    
                              printf("%s : %i.%i\n", statnum[qwe], stat[qwe][0],
                                stat[qwe][1]);
                        }
                        for (qwe = 0; qwe < 6; qwe++)
                          stat[qwe][1] = stat[qwe][1] + feed_chart[type - 3][food -
                            1][qwe];
    
    
                  }
    
            }
            while (exit_flag == 0);
    
            break;
          case 2:
            printf("new mag \n")
            ;printf("all stats have been reset\n\n\n");
            goto new_mag;
    
          case 3:
            printf("exit");
            return ;
    
            default: printf("error. try again \n");
    
      }
    
      return ;
    }

  4. #4
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    Is your compiler c++ only?
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    no its c\c++

  6. #6
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    ok... well not quite what i was expecting... but ok.

    you have an " int class " on line 29. your probably compiling this as a C++ program, so you cant name a variable 'class'.

    if you really dont want to change the name a solution might be renaming your source file with a .c extention and making sure that forced c++ compilation is turned off.

    but my recommendation is to change the variables name to something not reserved by the language.

  7. #7
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    first int main(void) then int stat[6][2] shoud be before your label for use with goto and you can't assign to "mag" like that must use
    Code:
    strcpy(name,"mag");
    and change the declaration of name to
    Code:
    char name[BUFSIZ];
    Last edited by linuxdude; 06-11-2004 at 09:47 PM.

  8. #8
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    you might just want to todally recode without goto's and such i can't even read your code to help you
    Woop?

  9. #9
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    whoa class is already a var? oops ill change that and try it

    ok it didnt work......i dont know i think i hit it with some thing large and heavy

  10. #10
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    class is a keyword in C++.

    same error?

  11. #11
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    and kl3pt0 if you want a visual ide which might make your life a bit easier check out
    http://www.bloodshed.net/dev/devcpp.html
    it will highlight c/c++ keywords
    Woop?

  12. #12
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    ok you also need to return a value from main, like return 0; instead of return ;

    and you need to do what linuxdude said.

  13. #13
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    ok hers new code
    Code:
    #include <stdio.h>
    #include <string.h>
    
    
    
    
    
    char *food_name[12] =
    {
      "", "monomate", "dimate", "trimate", "monofluid", "difluid", "trifluid",
        "antidote", "antipyralysis", "sol atomizer", "moon atomizer",
        "star atomizer"
    };
    char *classy_name[3] =
    {
      "hunter", "ranger", "force"
    };
    char *statnum[6] =
    {
      "SYNC", "IQ  ", "DEF ", "POW ", "DEX ", "MIND"
    };
    char *section_id[10] =
    {
      "viridia", "greenil", "skyly", "bluefull", "purplenum", "pinkal", "redria",
        "oran", "yellowboze", "whitill"
    };
    int ID;
    int classy ;
    char name[BUFSIZ];
    
    int error_flag = 0;
    int feed_flag = 1;
    char food;
    int exit_flag = 0;
    
    
    char feed_chart[5][11][6] =
    {
        {
            {
                3, 3, 5, 40, 5, 0
            } ,
            {
                3, 3, 10, 45, 5, 0
            }
            ,
            {
                4, 4, 15, 50, 10, 0
            }
            ,
            {
                3, 3, 5, 0, 5, 40
            }
            ,
            {
                3, 3, 10, 0, 5, 45
            }
            ,
            {
                4, 4, 15, 0, 10, 50
            }
            ,
            {
                3, 3, 5, 10, 40, 0
            }
            ,
            {
                3, 3, 5, 0, 44, 10
            }
            ,
            {
                4, 1, 15, 30, 15, 25
            }
            ,
            {
                4, 1, 15, 25, 15, 30
            }
            ,
            {
                6, 5, 25, 25, 25, 25
            }
        }
        ,
    
        {
            {
                0, 0, 5, 10, 0,  - 1
            }
            ,
            {
                2, 1, 6, 15, 3,  - 3
            }
            ,
            {
                3, 2, 12, 21, 4,  - 7
            }
            ,
            {
                0, 0, 5, 0, 0, 8
            }
            ,
            {
                2, 1, 7, 0, 3, 13
            }
            ,
            {
                3, 2, 7,  - 7, 6, 19
            }
            ,
            {
                0, 1, 0, 5, 15, 0
            }
            ,
            {
                2, 0,  - 1, 0, 14, 5
            }
            ,
            {
                 - 2, 2, 10, 11, 8, 0
            }
            ,
            {
                3,  - 2, 9, 0, 9, 11
            }
            ,
            {
                4, 3, 14, 9, 18, 11
            }
        }
        ,
    
        {
            {
                0,  - 1, 1, 9, 0,  - 5
            }
            ,
            {
                3, 0, 1, 13, 0,  - 10
            }
            ,
            {
                4, 1, 8, 16, 2,  - 15
            }
            ,
            {
                0,  - 1, 0,  - 5, 0, 9
            }
            ,
            {
                3, 0, 4,  - 10, 0, 13
            }
            ,
            {
                3, 2, 6,  - 15, 5, 17
            }
            ,
            {
                 - 1, 1,  - 5, 4, 12,  - 5
            }
            ,
            {
                0, 0,  - 5,  - 6, 11, 4
            }
            ,
            {
                4,  - 2, 0, 11, 3,  - 5
            }
            ,
            {
                 - 1, 1, 4,  - 5, 0, 11
            }
            ,
            {
                4, 2, 7, 8, 6, 9
            }
        }
        ,
    
        {
            {
                0,  - 1, 0, 3, 0, 0
            }
            ,
            {
                2, 0, 5, 7, 0,  - 5
            }
            ,
            {
                3, 1, 4, 14, 6,  - 10
            }
            ,
            {
                0, 0, 0, 0, 0, 4
            }
            ,
            {
                0, 1, 4,  - 5, 0, 8
            }
            ,
            {
                2, 2, 4,  - 10, 3, 15
            }
            ,
            {
                 - 3, 3, 0, 0, 7, 0
            }
            ,
            {
                3, 0,  - 4,  - 5, 20,  - 5
            }
            ,
            {
                3,  - 2,  - 10, 9, 6, 9
            }
            ,
            {
                 - 2, 2, 8, 5,  - 8, 7
            }
            ,
            {
                3, 2, 7, 7, 7, 7
            }
        }
        ,
    
        {
            {
                2,  - 1,  - 5, 9,  - 5, 0
            }
            ,
            {
                2, 0, 0, 11, 0,  - 10
            }
            ,
            {
                0, 1, 4, 14, 0,  - 15
            }
            ,
            {
                2,  - 1,  - 5, 0,  - 6, 10
            }
            ,
            {
                2, 0, 0,  - 10, 0, 11
            }
            ,
            {
                0, 1, 4,  - 15, 0, 15
            }
            ,
            {
                2,  - 1,  - 5,  - 5, 16,  - 5
            }
            ,
            {
                 - 2, 3, 7,  - 3, 0,  - 3
            }
            ,
            {
                4,  - 2, 5, 21,  - 5,  - 20
            }
            ,
            {
                3, 0,  - 5,  - 20, 5, 21
            }
            ,
            {
                3, 2, 4, 6, 8, 5
            }
        }
    };
    
    int I;
    int IDtype;
    int PB_ = 1; /*	 initialize PB	   */
    int type = 1; /*   initialize TYPE	*/
    int level = 5; /*	initialize LEVEL */
    int blah;
    int qwe = 0;
    int poke = 1;
    int comm;
    int stat[6][2];
    
    int main(void)
    {
      new_mag:     //makes a new mag 
      //get you section ID
      printf("Enter section ID \n");
      for (qwe; qwe < 10; qwe++)
      {
        printf("%i : %s\n", qwe, section_id[qwe]);
      }
      printf("Enter section ID \n");
      for (qwe = 0; qwe < 10; qwe++)
      {
        printf("%i : %s\n", qwe, section_id[qwe]);
      }
      scanf("%i", &ID);
      for (qwe = 0; qwe < 10; qwe++)
        if (qwe == ID)
          blah = 1;
      if (blah == 0)
        return ;
    
      printf("Enter character classy \n");
      for (qwe = 1; qwe < 4; qwe++)
      {
        printf("%i :	%s\n", qwe, classy_name[qwe - 1]);
      }
      scanf("%i", &classy );
      blah = 0;
      for (qwe = 0; qwe < 4; qwe++)
        if (qwe == classy )
          blah = 1;
      if (blah == 0)
        return ;
      classy --;
    
      for (qwe = 0; qwe < 9; qwe = qwe + 2)
      {
          if (ID == qwe)
          {
              blah = 0;
          }
      }
      if (blah == 0)
        IDtype = 1;
      else
        IDtype = 2;
    
      printf("your id type is %i \n", IDtype);
      printf("your section id is %s \n", section_id[ID]);
      printf("your classy is %s \n", classy_name[classy ]);
    
    
      for (qwe = 0; qwe < 6; qwe++)
        printf("%s is %i . %i \n", statnum[qwe], stat[qwe][0], stat[qwe][1]);
    
      strcpy(name,"mag");
      menue: printf("Enter command: \n");
      printf("1: feed \n");
      printf("2: new \n");
      printf("3: exit \n");
      scanf("%i", &comm);
      switch (comm)
      {
          case 1:
            do
            {
                  if (error_flag == 0)
                  {
                        printf("feed what?:\n");
                        if (feed_flag == 1)
                        {
                              for (qwe = 1; qwe < 12; qwe++)
                              {
                                    printf("%i : %s\n", qwe, food_name[qwe]);
                              }
    
                              printf("12 : to hide food chart \n");
                        }
                        else
                        {
                              printf("12 : to show food chart \n");
                        }
                  }
                  else
                  {
                        printf("Re-input: \n");
                  }
                  printf("13 : for menu \n");
                  error_flag = 0;
                  scanf("%i", &food);
                  if (food > 13)
                    return ;
                  switch (food)
                  {
                      case 12:
                        if (feed_flag == 0)
                          feed_flag = 1;
                        else
                          feed_flag = 0;
                        break;
                      case 13:
                        exit_flag = 1;
                        break;
                        default: printf("the item you picked is %s\n",
                          food_name[food]);
    
                        printf("\n the stat effects are\n\n");
                        for (qwe = 0; qwe < 6; qwe++)
                        {
    
                              printf("%s : %i.%i\n", statnum[qwe], stat[qwe][0],
                                stat[qwe][1]);
                        }
                        for (qwe = 0; qwe < 6; qwe++)
                          stat[qwe][1] = stat[qwe][1] + feed_chart[type - 3][food -
                            1][qwe];
    
    
                  }
    
            }
            while (exit_flag == 0);
    
            break;
          case 2:
            printf("new mag \n")
            ;printf("all stats have been reset\n\n\n");
            goto new_mag;
    
          case 3:
            printf("exit");
            return ;
    
            default: printf("error. try again \n");
    
      }
    
      return ;
    }

  14. #14
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    need to define/declare BUFSIZ

    add something like one of these this after your includes

    where 'n' is the size of the array, minimally 4...

    #define BUFSIZ n

    or

    const int BUFSIZ = n;


    and make alll your returns return something.

  15. #15
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    i got it to compile you just had need to remove this though
    Code:
      printf("Enter section ID \n");
      for (qwe; qwe < 10; qwe++)
      {
        printf("%i : %s\n", qwe, section_id[qwe]);
      }
     /*I need to go away cause im a duplicate :)
      printf("Enter section ID \n");
      for (qwe = 0; qwe < 10; qwe++)
      {
        printf("%i : %s\n", qwe, section_id[qwe]);
      }
     */
    Woop?

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Downing Street Memo
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 06-20-2005, 09:28 PM
  2. We missed REALLY big day (by about 17 hours)
    By major_small in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-20-2005, 06:53 PM
  3. Replies: 8
    Last Post: 04-07-2004, 01:29 PM
  4. Linker Errors = I think i missed a library?
    By DeepBlackMagic in forum Windows Programming
    Replies: 7
    Last Post: 09-07-2003, 01:00 PM
  5. Hello everyone - Bubba has missed all of you
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 01-20-2003, 08:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21