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; Originally Posted by prog-bman i got it to compile you just had need to remove this though Code: printf("Enter section ...

  1. #16
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    Quote Originally Posted by prog-bman
    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]);
      }
     */
    will you post your code? cuz i seem to mess it up when it touch it

  2. #17
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    ya kow what im goingto go to bed and take this think on in the moring with a clear head

  3. #18
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    good luck.

  4. #19
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >need to define/declare BUFSIZ
    BUFSIZ is defined in stdio.h

  5. #20
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    BUFSIZ is already defined in stdio.h
    [edit]beaten darnit[/edit]

  6. #21
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,812
    Hey just a word of advice try beaking the program into some functions it will make your life a heck of alot easier
    [edit]and you won't have to use goto's either this way[\edit]
    Woop?

  7. #22
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    ok this is how i have fixed up my program it compiles now but now when i run it i get a illegal operation
    Code:
    #include <stdio.h>
    #include <string.h>
    
    
    int classname(void) //gets charcter class
    {
    int charclass;
    printf("Enter character class\n");
    printf("1 : hunter\n");
    printf("2 : ranger\n");
    printf("3 : force\n");
      scanf("%i", charclass );
      charclass--;
    return (charclass);
    }
    
    
    int classid(void) //gets section ID
    {
    int ID;
      printf("Enter section ID \n");
        printf("0 : viridia\n");
        printf("1 : greenil\n");
        printf("2 : skyly\n");
        printf("3 : bluefull\n");
        printf("4 : purplenum\n");
        printf("5 : pinkal\n");
        printf("6 : redria\n");
        printf("7 : oran\n");
        printf("8 : yellowboze\n");
        printf("9 : whitill\n");
      scanf("%i", &ID);
    return (ID); 
    }
    
    int num_check(int ID,int charclass)//
    {
    int check=0;
    int check2=0;
    int qwe;
    	for (qwe = 0; qwe < 10; qwe++) if (qwe == ID)check=1;
    	for (qwe = 0; qwe <  4; qwe++) if (qwe == charclass)check2=1;
    	check=check+check2;
        return(check);
    }
    
    int id_check(int ID)
    {
    int qwe;
    int IDtype;
    int blah=1;
      for (qwe = 0; qwe < 9; qwe = qwe + 2)if (ID == qwe)blah = 0;
      if (blah == 0)IDtype = 1; else IDtype = 2;
      return(IDtype);
    }
    
    int menue(void)
    {
    int comm;
    
    }
    
    
    int food_name(int flag)
    {
    int food;
    	printf("feed what?:\n");
     if (flag == 1)
      {
        printf("1  : monomate\n");
        printf("2  : dimate\n");
        printf("3  : trimate\n");
        printf("4  : monofluid\n"); 
        printf("5  : difluid\n");
        printf("6  : trifluid\n");
        printf("7  : antidote\n");
       	printf("8  : antipyralysis\n");
       	printf("9  : sol atomizer\n");
       	printf("10 : moon atomizer\n");
       	printf("11 : star atomizer\n");
       	printf("12 : to hide food chart \n");
       	printf("13 : for menu \n");
       	scanf("%i", &food);
      }
      else
      {
      	printf("1 : to show food chart \n");
      	printf("2 : for menu \n");
      	scanf("%i", &food);
      	food=food+11;
      }
      return(food);
    };
    char *classy_name[3] =
    {
    
    };
    char *statnum[6] =
    {
      "SYNC", "IQ  ", "DEF ", "POW ", "DEX ", "MIND"
    };
    
    
    int comm;
    
    
    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 blah;
    int qwe = 0;
    int poke = 1;
    int newmag_flag;
    
    
    
    int main(void)
    {
    
    struct
     {
      int new_flag;
      int ID;
      int charclass;
      int stat[6][2];
      int PB_;
      int type;
      int IDtype; 
      int level;
      char name[BUFSIZ];
     }mag;
    
    
    do{
     strcpy(mag.name,"mag");
     mag.PB_     = 1;
     mag.type    = 1; 
     mag.level   = 5;
     mag.new_flag= 0;
      //get you section ID
      mag.ID=classid();
    
      //get class name
      mag.charclass=classname();
    
    
     //makes shure inputs are correct
     if (num_check(mag.ID,mag.charclass)<2)return(0);
    
     //gets ID for lv50 evo
     mag.IDtype=id_check(mag.ID);
    
    
    
     do
     {  
     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)
                  {
                  		food=food_name(feed_flag);
                  }
                  else
                  {
                        printf("Re-input: \n");
                        scanf("%i", &food);
                  }
                  
                  error_flag = 0;
                  
                  if (food > 13)
                    return(0) ;
                  switch (food)
                  {
                      case 12:
                        if (feed_flag == 0)
                          feed_flag = 1;
                        else
                          feed_flag = 0;
                        break;
                      case 13:
                        exit_flag = 1;
                        break;
                        default: 
    
                        printf("\n the stat effects are\n\n");
                        for (qwe = 0; qwe < 6; qwe++)
                        {
    
                              printf("%s : %i.%i\n", statnum[qwe], mag.stat[qwe][0],
                                mag.stat[qwe][1]);
                        }
                        for (qwe = 0; qwe < 6; qwe++)
                          mag.stat[qwe][1] = mag.stat[qwe][1] + feed_chart[mag.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");
            mag.new_flag=1;
    
          case 3:
            printf("exit");
            mag.new_flag=1;
            blah=55;
    
          default:
          	printf("error. try again \n");
        }
     }
     while (mag.new_flag==0);
    }
    while(blah!=55);
      return(0) ;
    }

  8. #23
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    Code:
      scanf("%i", charclass );
    should be
    Code:
    scanf("%d",& charclass);
    unless you want different basses exctal and hex
    the missing & creates your segfault you don't need the & only on arrays

  9. #24
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    oh opps i must have missed those when i re
    wrote it

  10. #25
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    you don't need the & only on arrays
    Not so. You don't need it on pointers. Thus, when reading a string, you just use the name of the array, which is treated as if it were a pointer in that case. If you wanted to read into an array of integers or what not, you'd still need the address-of operator:
    Code:
    scanf("%d", &array[cell] );
    Quzah.
    Hope is the first step on the road to disappointment.

  11. #26
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    You knew what I meant
    I was thinking about saying all that, but I decided not to for him. I forgot about you

  12. #27
    Registered User
    Join Date
    Jun 2004
    Posts
    21
    ok i got every thing running but im getting 2 phrase errors at the very end now on line 320 and 327
    Code:
    #include <stdio.h>
    #include <string.h>
    
    
    int classname(void) //gets charcter class
    {
    int charclass;
    printf("Enter character class\n");
    printf("0 : hunter\n");
    printf("1 : ranger\n");
    printf("2 : force\n");
      scanf("%i", &charclass );
    return (charclass);
    }
    
    
    int classid(void) //gets section ID
    {
    int ID;
      printf("Enter section ID \n");
        printf("0 : viridia\n");
        printf("1 : greenil\n");
        printf("2 : skyly\n");
        printf("3 : bluefull\n");
        printf("4 : purplenum\n");
        printf("5 : pinkal\n");
        printf("6 : redria\n");
        printf("7 : oran\n");
        printf("8 : yellowboze\n");
        printf("9 : whitill\n");
      scanf("%i", &ID);
    return (ID); 
    }
    
    
    
    
    int num_check(int ID,int charclass)//
    {
    int check=0;
    int check2=0;
    int qwe;
    	for (qwe = 0; qwe < 10; qwe++) if (qwe == ID)check=1;
    	for (qwe = 0; qwe <  4; qwe++) if (qwe == charclass)check2=1;
    	check=check+check2;
        return(check);
    }
    
    int id_check(int ID)
    {
    int qwe;
    int IDtype;
    int blah=1;
      for (qwe = 0; qwe < 9; qwe = qwe + 2)if (ID == qwe)blah = 0;
      if (blah == 0)IDtype = 1; else IDtype = 2;
      return(IDtype);
    }
    
    int feed(stat,food)
    {
    stat= stat+food;
    if (stat<0)stat=0;
    return(stat);
    }
    
    
    int food_name(int flag)
    {
    int food;
    	printf("feed what?:\n");
     if (flag == 1)
      {
        printf("1  : monomate\n");
        printf("2  : dimate\n");
        printf("3  : trimate\n");
        printf("4  : monofluid\n"); 
        printf("5  : difluid\n");
        printf("6  : trifluid\n");
        printf("7  : antidote\n");
       	printf("8  : antipyralysis\n");
       	printf("9  : sol atomizer\n");
       	printf("10 : moon atomizer\n");
       	printf("11 : star atomizer\n");
       	printf("12 : to hide food chart \n");
       	printf("13 : for menu \n");
       	scanf("%i", &food);
      }
      else
      {
      	printf("12 : to show food chart \n");
      	printf("13 : for menu \n");
      	scanf("%i", &food);
    
      }
      food--;
      return(food);
    };
    
    
    
    char *statnum[6] =
    {
      "SYNC", "IQ  ", "DEF ", "POW ", "DEX ", "MIND"
    };
    
    
    int comm;
    
    
    
    
    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 blah;
    int qwe = 0;
    int poke = 1;
    
    int main(void)
    {
    
    struct
     {
      int new_flag;
      int ID;
      int charclass;
      int stat[6][2];
      int PB_;
      int type;
      int IDtype; 
      int level;
      char name[BUFSIZ];
     }mag;
    
    
    do{
    int error_flag = 0;
    int feed_flag = 1;
    char food;
    int exit_flag = 0;
    
    
     strcpy(mag.name,"mag");
     mag.PB_     = 1;
     mag.type    = 1; 
     mag.level   = 5;
     mag.new_flag= 0;
     mag.stat[0][0]=40;
     mag.stat[1][0]=0;
     mag.stat[2][0]=5;
     mag.stat[3][0]=0;
     mag.stat[4][0]=0;
     mag.stat[5][0]=0;
     mag.stat[0][1]=0;
     mag.stat[1][1]=0;
     mag.stat[2][1]=0;
     mag.stat[3][1]=0;
     mag.stat[4][1]=0;
     mag.stat[5][1]=0;
       //get you section ID
      mag.ID=classid();
    
      //get class name
      mag.charclass=classname();
    
    
     //makes shure inputs are correct
     if (num_check(mag.ID,mag.charclass)<2)return(0);
    
     //gets ID for lv50 evo
     mag.IDtype=id_check(mag.ID);
    
    
    
     do
     {  
     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)
                  {
                  		food=food_name(feed_flag);
                  }
                  else
                  {
                        printf("Re-input: \n");
                        scanf("%i", &food);
                  }
                  
                  error_flag = 0;
                  
                  if (food > 12)
                    return(0) ;
                  switch (food)
                  {
                      case 11:
                        if (feed_flag == 0)
                          feed_flag = 1;
                        else
                          feed_flag = 0;
                        break;
                      case 12:
                        exit_flag = 1;
                        break;
                        default: 
                        	for (qwe = 0; qwe < 6; qwe++)
                        	{
                               	mag.stat[qwe][1]=feed(mag.stat[qwe][1],feed_chart[mag.type][food-11][qwe]);
                               	                           	
                                if(mag.stat[qwe][1]>99)
                                {
                                mag.stat[qwe][1]=mag.stat[qwe][1]-100;
                                mag.stat[qwe][0]++;
                                mag.level++;
                                printf("level up!!\n");            
                            }
                        for (qwe = 0; qwe < 6; qwe++)
                        {
    
                              printf("%s : %i.%i\n", statnum[qwe], mag.stat[qwe][0],mag.stat[qwe][1]);
                        }
    
                        break;
    
                  }
    
            }
            while (exit_flag == 0);
    
          break;
          case 2:
            mag.new_flag=1;
          break;
          case 3:
            printf("exit");
            return (1);
    
          default:
          	printf("error. try again \n");
          break;
        }
        
     }                        /*line 320*/
     while (mag.new_flag==0); 
    }
    while(blah!=55);
      return(0);
    }
     /*line 327*/

  13. #28
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    That means that your { and } don't all fit you have too many of the {. I don't like the indentation style of your code and it hurts to look through it. I see a nested do loop, maybe over there somewhere. Looking at the errors and finding them is all part of the fun and learning experience. Hope you find it.

Page 2 of 2 FirstFirst 12
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, 10: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, 07:53 PM
  3. Replies: 8
    Last Post: 04-07-2004, 02:29 PM
  4. Linker Errors = I think i missed a library?
    By DeepBlackMagic in forum Windows Programming
    Replies: 7
    Last Post: 09-07-2003, 02: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, 09:33 AM

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