Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3281798
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:51:21+00:00 2026-05-17T19:51:21+00:00

I was asked an interview question to change the entry point of a C

  • 0

I was asked an interview question to change the entry point of a C or C++ program from main() to any other function. How is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:51:22+00:00Added an answer on May 17, 2026 at 7:51 pm

    In standard C (and, I believe, C++ as well), you can’t, at least not for a hosted environment (but see below). The standard specifies that the starting point for the C code is main. The standard (c99) doesn’t leave much scope for argument:

    5.1.2.2.1 Program startup: (1) The function called at program startup is named main.

    That’s it. It then waffles on a bit about parameters and return values but there’s really no leeway there for changing the name.

    That’s for a hosted environment. The standard also allows for a freestanding environment (i.e., no OS, for things like embedded systems). For a freestanding environment:

    In a freestanding environment (in which C program execution may take place without any benefit of an operating system), the name and type of the function called at program startup are implementation-defined. Any library facilities available to a freestanding program, other than the minimal set required by clause 4, are implementation-defined.

    You can use “trickery” in C implementations so that you can make it look like main isn’t the entry point. This is in fact what early Windows compliers did to mark WinMain as the start point.


    First way: a linker may include some pre-main startup code in a file like start.o and it is this piece of code which runs to set up the C environment then call main. There’s nothing to stop you replacing that with something that calls bob instead.


    Second way: some linkers provide that very option with a command-line switch so that you can change it without recompiling the startup code.


    Third way: you can link with this piece of code:

    int main (int c, char *v[]) { return bob (c, v); }
    

    and then your entry point for your code is seemingly bob rather than main.


    However, all this, while of possibly academic interest, doesn’t change the fact that I can’t think of one single solitary situation in my many decades of cutting code, where this would be either necessary or desirable.

    I would be asking the interviewer: why would you want to do this?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This was the question asked in interview. Can we call one constructor from another
I was asked in my interview question there is a convenient PHP function you
This question was asked in my interview. random(0,1) is a function that generates integers
It was an interview question. I was asked to implement the StringBuffer append function.
Possible Duplicate: C++ virtual function from constructor Calling virtual functions inside constructors This question
I was asked in an interview,a question from oracle sql.this seemed to be a
I came across a interview question that asked to remove the repeated char from
Possible Duplicate: Oracle table change monitor This is the question that is asked to
I was asked this as interview question. Couldn't answer. Write a C program to
This is an interview Question that i was asked recently: Write a C program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.