CrazyEngineers
  • C Program without main()

    Neeraj Sharma

    Neeraj Sharma

    @neeraj-iAaNcG
    Updated: Oct 21, 2024
    Views: 865
    Here's a C programming challenge: Can you write a C program without main()? If yes, post your code below and I will take a look.
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Ankita Katdare

    AdministratorMar 15, 2012

    Nick_Sharma
    Can you write a C program without main() ??
    We had a similar thread for JAVA.
    Check : #-Link-Snipped-#

    It is quite possible to write a C program without main() if we know how to use preprocessor and macro.
    Are you sure? This action cannot be undone.
    Cancel
  • Neeraj Sharma

    MemberMar 15, 2012

    Yes it is possible using macros.I wanted it to be a kind of quiz 😛 Sorry may be I posted in wrong section 😔
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorMar 15, 2012

    Nick_Sharma
    Yes it is possible using macros.I wanted it to be a kind of quiz 😛 Sorry may be I posted in wrong section 😔
    This is the right section. 👍
    Let us keep this open for responses.
    Are you sure? This action cannot be undone.
    Cancel
  • Neeraj Sharma

    MemberMar 16, 2012

    This is actually the solution. Yes, we can write a program without main logically but it is not possible conceptually..
    Here is the program:

    #include<stdio.h>
    #include<conio.h>
    #define decode(a,u,d,i,b,l,e) i##a##d##u
    #define START decode(a,n,i,m,a,t,e)
    void START()
    {
    clrscr();
    printf("Hey this is Nick waving hi from a program without main");
    getch();
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register