I'm making this program and keeps telling me these errors:
35 expected `;' before ':' token
35 expected primary-expression before ':' token
35 expected `;' before ':' token
17 label `ins' used but not defined

I can't seem to find what the error is, it may only be a simple error or something wrong with my goto syntax, I posted it here, hoping to find advice since this is only the second time I'm trying something with the goto syntax

I made the rest of the code comments since they contain the same errors

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
  FILE *input, *output;
  char a[5000];
  int x=1,y;
  input = fopen("output4.txt","r");
  output = fopen("output5.txt","w");
      if(a[0]=='D' && a[1]=='E' && a[2]=='C') goto ins;
      else if(a[0]=='A' && a[1]=='D' && a[2]=='D') goto ins;
      //else if(a[0]=='A' && a[1]=='D' && a[2]=='D' && a[3]=='C')goto ins2;
      else if(a[0]=='A' && a[1]=='N' && a[2]=='L') goto ins;
      else if(a[0]=='X' && a[1]=='R' && a[2]=='L') goto ins;
      else if(a[0]=='M' && a[1]=='O' && a[2]=='V') goto ins;
      //else if(a[0]=='C' && a[1]=='J' && a[2]=='N' && a[3]=='E')goto ins2;
      //else if(a[0]=='A' && a[1]=='C' && a[2]=='A' && a[3]=='L' && a[4]=='L')goto ins3;
      //else if(a[0]=='d' && a[1]=='i' && a[2]=='r' && a[3]=='e' && a[4]=='c' && a[5]=='t')goto byte;
      //else if(a[0]=='#' && a[1]=='i' && a[2]=='m' && a[3]=='m' && a[4]=='e' && a[5]=='d')goto data;
      //else if(a[0]=='a' && a[1]=='d' && a[2]=='d' && a[3]=='r' && a[4]=='1' && a[5]=='1')goto memadd;
      //else if(a[0]=='o' && a[1]=='f' && a[2]=='f' && a[3]=='s' && a[4]=='e' && a[5]=='t')goto rel;
      //else if(a[0]=='b' && a[1]=='i' && a[2]=='t')goto bit;
      //else if(a[0]=='@' && a[1]=='R' && a[2]=='0' || a[2]=='1')goto memadd;
      //else if(a[0]=='R' && a[1]=='1' || a[1]=='6' || a[1]=='0' || a[1]=='5' || a[1]=='4' || a[1]=='3')goto reg;
      //else if(a[0]=='A')goto acc;
      else if(a[x]==10){continue; x=1;}
    goto ins: fprintf(output,"%c%c%c\t\t<ins>\n",a[0],a[1],a[2]); x=0;
    /*goto ins2: 
         fprintf(output,"%c%c%c%c\t\t<ins>\n",a[0],a[1],a[2],a[3]); x=0;
    goto ins2: 
         fprintf(output,"%c%c%c%c%c\t\t<ins>\n",a[0],a[1],a[2],a[3],a[4]); x=0;
    goto byte: 
         fprintf(output,"%c%c%c%c%c%c\t\t<byte>\n",a[0],a[1],a[2],a[3],a[4],a[5]); x=0;
    goto data: 
         fprintf(output,"%c%c%c%c%c%c\t\t<data>\n",a[0],a[1],a[2],a[3],a[4],a[5]); x=0;
    goto addr: 
         fprintf(output,"%c%c%c%c%c%c\t\t<addr>\n",a[0],a[1],a[2],a[3],a[4],a[5]); x=0;
    goto rel: 
         fprintf(output,"%c%c%c%c%c%c\t\t<rel>\n",a[0],a[1],a[2],a[3],a[4],a[5]); x=0;
    goto bit: 
         fprintf(output,"%c%c%c\t\t<bit>\n",a[0],a[1],a[2]); x=0;
    goto memadd: 
         fprintf(output,"%c%c%c\t\t<memadd>\n",a[0],a[1],a[2]); x=0;
    goto reg: 
         fprintf(output,"%c%c\t\t<reg>\n",a[0],a[1]); x=0;
    goto acc: 
         fprintf(output,"%c\t\t<acc>\n",a[0]); x=0;*/
  return 0;
9 Years
Discussion Span
Last Post by gallantmon1

Go to statements go like this:

/* create the label */
/* then call the goto */
    goto ins;

Substitute every goto <label>: that you have for <label>: or goto <label>; depending on if is a call or a label.
BTW. What a fine example of why goto shouldn't be used. You have a "messed up" code that doesn't even work, but because there's so many jumps with goto I am not inclined to find out why it doesn't work.


You need the proper input file to make it work, but thanks for what you said. I can't believe I made such an obvious mistake in using the goto statement

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.