Exforsys

Online Training

without main function how can we run c program

This is a discussion on without main function how can we run c program within the C and C++ forums, part of the Programming Talk category; Hi How can we run a " C Langauge program without writing the main function It is possible to do ...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-03-2007, 03:06 AM
Junior Member
 
Join Date: Feb 2007
Posts: 2
Dharmesh rathod is on a distinguished road
without main function how can we run c program

Hi

How can we run a " C Langauge program without writing the main function

It is possible to do it. but can anyone explain this with an example?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-13-2007, 11:12 PM
Senior Member
 
Join Date: Apr 2006
Posts: 141
Adrian is on a distinguished road
When a C program is executed the main() is the function called by the run-time environment. But it is possible to write C program without main() function with some trick. I have not done this but will make a try and let you know. Nice question posted which triggered me to try this out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-16-2007, 12:24 AM
Junior Member
 
Join Date: Mar 2007
Posts: 5
shrikant telkar is on a distinguished road
shri code

Quote:
Originally Posted by Dharmesh rathod View Post
Hi

How can we run a " C Langauge program without writing the main function

It is possible to do it. but can anyone explain this with an example?
thank you. ..........................................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-08-2008, 07:45 AM
Junior Member
 
Join Date: Jul 2008
Posts: 1
easysameer is on a distinguished road
Smile without main function how can we run c program

#include<stdio.h>
#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)

int begin()
{
printf(" hello ");
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-30-2008, 03:03 PM
Junior Member
 
Join Date: Jul 2008
Posts: 1
Skunk is on a distinguished road
Quote:
Originally Posted by easysameer View Post
Code:
#include<stdio.h>
#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)

int begin()
{
printf(" hello ");
}
I disagree - clever though.

That's still has a main function. If you trace through what the #define's are doing it's just changing "begin()" to "main()". The compiler still sees and compiles "main()".

It sounded like Dharmesh rathod wanted no main function whatsoever rather than obfuscated code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-01-2008, 09:01 AM
Junior Member
 
Join Date: Aug 2008
Posts: 2
pratap kumar is on a distinguished road
ans

Quote:
Originally Posted by Dharmesh rathod View Post
Hi

How can we run a " C Langauge program without writing the main function

It is possible to do it. but can anyone explain this with an example?

a program must have a main function (compulsory) without main it is impossible
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-16-2008, 04:31 AM
zephyr's Avatar
Member
 
Join Date: Dec 2007
Posts: 36
zephyr is on a distinguished road
As I know its not possible to run a program without the main function.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-15-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-01-2004 07:01 AM
comp.lang.c FAQ list Table of Contents Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 07:00 AM


All times are GMT -4. The time now is 06:59 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.