Thread: parse error before string constant

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    parse error before string constant

    Trying to do a simple program, well I thought it was going to be simple...

    It's meant to create a muliplication table, dimensions are the user's discretion.

    Code:
    #include <stdio.h>
    int main(void)
    {
       int a,b,n;
       printf("Multiplication Table size? - ");
       scanf(" %d",&n);
       printf("  |");
       for(a=2;a<=n,a++) {
          printf("  %d",a);
       }
       printf("\n==");
       for(a=2;a<=n,a++) {
          printf("====");
       }
       printf(" \n");
       for(a=2;a<=n;a++) {
          printf("%d |",a);
          for(b=1;b<=n;b++) {
             printf(" %d",a*b);
          }
          printf(" \n");
       }
       return 0;
    }

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    #include <stdio.h>
    int main(void)
    {
       int a,b,n;
       printf("Multiplication Table size? - ");
       scanf(" &#37;d",&n);
       printf("  |");
       for(a=2;a<=n;a++) {
          printf("  %d",a);
       }
       printf("\n==");
       for(a=2;a<=n;a++) {
          printf("====");
       }
       printf(" \n");
       for(a=2;a<=n;a++) {
          printf("%d |",a);
          for(b=1;b<=n;b++) {
             printf(" %d",a*b);
          }
          printf(" \n");
       }
       return 0;
    }
    You had a couple ',' instead of ';' in two of your for loops.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    2
    haha, so I do.
    Thanks for pointing out the obvious . Code is now working, many thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  3. Parse Error Before String Constant?
    By xombie in forum C Programming
    Replies: 4
    Last Post: 10-08-2004, 01:17 AM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM