error in code

This is a discussion on error in code within the C Programming forums, part of the General Programming Boards category; #include<stdio.h> void main() { float PersonID,Wage,Sex,Age,n; float a[10][10]; printf("please enter the amount of people you will use \n\r"); scanf("%d",&n); for(PersonID=1;PersonID<=n;PersonID++); ...

  1. #1
    Unregistered
    Guest

    Cool error in code

    #include<stdio.h>
    void main()
    {
    float PersonID,Wage,Sex,Age,n;
    float a[10][10];
    printf("please enter the amount of people you will use \n\r");
    scanf("%d",&n);
    for(PersonID=1;PersonID<=n;PersonID++);
    {
    printf("please enter the Person ID of the client \n\r");
    scanf("%d,&a[PersonID][10]);
    }
    }


    Hi can someone tell me why I am getting errors in this code plz thanks !

  2. #2
    Registered User jasrajva's Avatar
    Join Date
    Oct 2001
    Posts
    99
    1)
    use integers for n and PersonID

    anyway you are doing scanf(%d) on a float so you'll cause hell

    and

    you cannot use a float in a array subscript

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    printf("please enter the amount of people you will use \n\r");

    only needs to be...

    printf("please enter the amount of people you will use \n");

    scanf("%d,&a[PersonID][10]);

    should be

    scanf("%d",&a[PersonID][10]);

    void main() is illegal.....
    use
    int main()
    {
    ...
    ...
    return 0;
    }
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You might still get warnings cuz Wage, Sex & Age are unused at this time....

  5. #5
    Unregistered
    Guest

    Talking

    cheers for all your help !!!!!!! much appreciated

    oh yeah optical mouses rule !

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

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