#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Linker Error : Undefined symbol _main in module c0.ASM


    Sir,

    I had written a program in c like this:
    #include<stdio.h>
    voidmain()
    {
    int p, n;
    float r, si;
    printf("Enter Value of p,n,r,");
    scanf("%d%d%f, &p,&n,&r,");

    si=p*n*r/100;
    printf ("%f", si);
    return 0;
    }
    while compling , it gives me error,
    Linker Error : Undefined symbol _main in module c0.ASM

    Please Help me

    viralmand
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    54
    Rep Power
    0
    give a space between void and main. :eh:
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    54
    Rep Power
    0
    Originally Posted by viralmand
    Sir,

    I had written a program in c like this:

    #include<stdio.h>
    voidmain() ( SPACE GOES HERE)


    return 0; (NO NEED OF THIS - u sud be getting a warning)

    viralmand

    give a space between void and main. :eh:
  6. #4
  7. Who set my Title?
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2004
    Posts
    715
    Rep Power
    261
    It should have been
    Code:
    int main()
    void is not a standard return type for main.
    Nobody is perfect. I am Nobody.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    54
    Rep Power
    0
    Originally Posted by LaughingBelly
    It should have been
    Code:
    int main()
    void is not a standard return type for main.
    Actually this particular error is being generated because he didn't use a space between void and main, and the compiler is not recognizing "voidmain". Also it is a proper standard to int main and return(0), instead of void(to viralmand). But by just using the space as I mentioned in my earlier post should solve the problem,(to viralmand again) but if your bent on using void there is no need for the statement return(0).

    Comments on this post

    • LaughingBelly disagrees : Please stop confusing people. It is always good to get them started on the correct way of using main.
  10. #6
  11. Who set my Title?
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2004
    Posts
    715
    Rep Power
    261
    While void main will take make it compile without errors, it won't be without warnings. It is better that he learns the correct way of using it instead of band-aid solutions.

    Comments on this post

    • the eVil piXel agrees : agreed
    Nobody is perfect. I am Nobody.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Thanks


    Thanks you all for the valuable suggestions

IMN logo majestic logo threadwatch logo seochat tools logo