please help me..
Yes it is possible to write a program in c without using main.
Here is the code: -
/* prog_without_main.c */
-
_start()
-
{
-
_exit(my_main());
-
}
-
int my_main(void)
-
{
-
printf(”Hello\n”);
-
return 42;
-
}
And use this command (% is command prompt) to compile:
%gcc -O3 -nostartfiles prog_without_main.c
Try compiling this example: -
#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)
-
void begin()
-
{
-
printf(”hello”);
-
}
here is how it works once we say define we need to understand that
#define x y
then ‘x’ ix replaced by ‘y’
similarly in this case
#define begin decode(a,n,i,m,a,t,e)
decode(a,n,i,m,a,t,e) is replaced by m##a##i##n
bcoz s is replaced by a,t by n,u by i and so on
s->a
t->n
u->i
m->m
p->a
e->t
d->e
now the statement becomes
void m##a##i##n
And u must be knowing that ## is used for string concatenation so it becomes
“main”
finally the code crops down to -
void main()
-
{
-
printf(”hello”);
-
}
4 7026
please help me..
Yes it is possible to write a program in c without using main.
Here is the code:
...
This most certainly belongs in the C/C++ Forum! ^^
Greetings,
Nepomuk
Hi bagkalyan and welcome to TSDN,
As this post is a technical question related to c/c++, I have moved it from the cafe to the appropriate forum.
Take a moment to read the posting guidelines for this site here.
MODERATOR
please help me..
Yes it is possible to write a program in c without using main.
Here is the code:
/* prog_without_main.c */
_start()
{
_exit(my_main());
}
int my_main(void)
{
printf(”Hello\n”);
return 42;
}
And use this command (% is command prompt) to compile:
%gcc -O3 -nostartfiles prog_without_main.c
Try compiling this example:
#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)
void begin()
{
printf(”hello”);
}
here is how it works once we say define we need to understand that
#define x y
then ‘x’ ix replaced by ‘y’
similarly in this case
#define begin decode(a,n,i,m,a,t,e)
decode(a,n,i,m,a,t,e) is replaced by m##a##i##n
bcoz s is replaced by a,t by n,u by i and so on
s->a
t->n
u->i
m->m
p->a
e->t
d->e
now the statement becomes
void m##a##i##n
And u must be knowing that ## is used for string concatenation so it becomes
“main”
finally the code crops down to
void main()
{
printf(”hello”);
}
The second really isn't a program without main. Like you said, it comes to the compiler like:
Anyway, what is your question?
The second really isn't a program without main. Like you said, it comes to the compiler like:
Erm, it's "int", not "void". "int"; remember that: int, int, int, intintintintintintint!
kind regards,
Jos ;-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Klaus Neuner |
last post by:
Hello,
I want to write a class Recognizer, like so:
class Recognizer(object):
def is_of_category_1(self, token):
if token == 1:
return "1"
else:
|
by: Disiac |
last post by:
Hi,
MS Class Library Guidelines clearly discourages use of Write-Only properties
yet they're continuously availed in .NET after VB 6. Personally, I really
don't use them anywhere. Tend to find...
|
by: Eli |
last post by:
I've got a script that I'm trying to debug which uses document.write()
to place HTML within a page. In both IE6 and Firefox when I view
source, I see only the script itself and not any HTML as...
|
by: Eric Mitchell |
last post by:
Hello all,
I am using the document.write() method to create new content on the same
page, however... I need to create a new button using this method (button in
HTML). Complicating the matter...
|
by: Gav |
last post by:
Hi all,
I have created a user control and I am using Response.Write in the control
to 'write' exactly what I want although it always goes to the top of the
page (above <HTML><HEAD> etc). Can I...
|
by: Farooq Khan |
last post by:
why does Response.Write in a method of code-beind class when called from
inpage code (i.e in <%---%>), after creating object of that class, fails
when called
while it works perfectly ok while...
|
by: Phil Sandler |
last post by:
Hello all,
Thanks in advance for any help with this.
I am trying to get sample code to run from Michael Russell's
excellent article on removing whitespace:...
|
by: Buddy Home |
last post by:
Hello,
I'm trying to upload a file programatically and occasionally I get the
following error message.
Unable to write data to the transport connection: An established connection
was aborted...
|
by: Buddy Home |
last post by:
Hello,
I'm trying to upload a file programatically and occasionally I get the
following error message.
Unable to write data to the transport connection: An established connection
was aborted...
|
by: martinmercy2001 |
last post by:
Could any body help me with creating a ring buffer class using a string. use memory circular buffer not an IO buffer. just read, write and seek method. Read method should take anumber and return the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |