473,789 Members | 3,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A program which would print out it's own source code - possible ornot?


Is it possible to write a program which would print out it's own
source code, using C++?
Jan 23 '08 #1
21 3589
mi******@gmail. com wrote:
Is it possible to write a program which would print out it's own
source code, using C++?
Yes.

- Jensen
Jan 23 '08 #2
On 23 Jan, 11:15, mikha...@gmail. com wrote:
Is it possible to write a program which would print out it's own
source code, using C++?
Google "quine".
Jan 23 '08 #3
mi******@gmail. com wrote:
Is it possible to write a program which would print out it's own
source code, using C++?
yes, here is one example for free:
Jan 23 '08 #4
On 2008-01-23 10:24:30 -0500, anon <an**@no.nosaid :
mi******@gmail. com wrote:
>Is it possible to write a program which would print out it's own
source code, using C++?

yes, here is one example for free:
deep, philosophically ... lol.

--

-kira

Jan 23 '08 #5
Kira Yamato wrote:
On 2008-01-23 10:24:30 -0500, anon <an**@no.nosaid :
>mi******@gmail. com wrote:
>>Is it possible to write a program which would print out it's own
source code, using C++?

yes, here is one example for free:

deep, philosophically ... lol.
It probably is. But my dumb compiler complains that there is no
'main' in my program...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 23 '08 #6
mi******@gmail. com writes:
Is it possible to write a program which would print out it's own
source code, using C++?
Yes, that's trivial.

--
__Pascal Bourguignon__ http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
Jan 23 '08 #7
"Victor Bazarov" <v.********@com Acast.netwrites :
Kira Yamato wrote:
>On 2008-01-23 10:24:30 -0500, anon <an**@no.nosaid :
>>mi******@gmail. com wrote:
Is it possible to write a program which would print out it's own
source code, using C++?

yes, here is one example for free:

deep, philosophically ... lol.

It probably is. But my dumb compiler complains that there is no
'main' in my program...
Ok, so you need at least a main.

int main(){
// add something here...
return 0;
}
--
__Pascal Bourguignon__ http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
Jan 23 '08 #8
Pascal Bourguignon wrote:
"Victor Bazarov" <v.********@com Acast.netwrites :
>Kira Yamato wrote:
>>On 2008-01-23 10:24:30 -0500, anon <an**@no.nosaid :

mi******@gmail. com wrote:
Is it possible to write a program which would print out it's own
source code, using C++?

yes, here is one example for free:

deep, philosophically ... lol.

It probably is. But my dumb compiler complains that there is no
'main' in my program...

Ok, so you need at least a main.

int main(){
// add something here...
return 0;
}
Weird. This one doesn't print its own source code. Why?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 23 '08 #9
Victor Bazarov wrote:
Pascal Bourguignon wrote:
>"Victor Bazarov" <v.********@com Acast.netwrites :
>>Kira Yamato wrote:
On 2008-01-23 10:24:30 -0500, anon <an**@no.nosaid :

mi******@gmail. com wrote:
>Is it possible to write a program which would print out it's own
>source code, using C++?
yes, here is one example for free:
deep, philosophically ... lol.
It probably is. But my dumb compiler complains that there is no
'main' in my program...
Ok, so you need at least a main.

int main(){
// add something here...
return 0;
}

Weird. This one doesn't print its own source code. Why?

V
Allow me to correct Pascal's code:

int main()
{
// add something here to print its own source.
// this is left as an exercise to the reader
return 0;
}

Jan 23 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14169
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
1
2365
by: Hung Jung Lu | last post by:
Hi, I have been looking into AOP (Aspect-Oriented Programming) for sometime, now. I frankly don't like the syntax of any of the approaches I have seen so far. I am kind playing around with some ideas, and maybe write up an article later. AOP is not just buzzword. It's not just callback, it's not just Ruby's MixIn, it's not just Python's metaclass, it's not just C++'s template. AOP can be implemented/considered as a subset of...
5
1476
by: aleksander.helgaker | last post by:
I've completely rewritten a calculator I wrote to help me learn Python. After someone told me about the def command I reliesed that I could make the program much better, but there is a very anoying problem which ocours when I run the program. Here is the code <code> # IMPOSRTS # import sys import os
5
1783
by: Henry Jordon | last post by:
hello I was wondering if someone could help me get a main going on this project I've completed the header file that the professor started us on but not really sure how to get the main going. If someone could please give me some pointers it would greatly be appreciated. Again thanks for the help. Henry headerfile:
4
7066
by: yinglcs | last post by:
I am trying to debug a C++ program in GDB on linux. I want to dump out the content of the "this" object, Here is what I get: (gdb) print *this $2 = {path = <incomplete type>} My question is why I don't see the content of 'path'? It said '<incomplete type>'. In the code, path is:
9
7880
by: sandy | last post by:
Hey guys, I know this is silly, but I just wanted to take some break from work. I was just wodering if its possible to write a c++ program that can print "iloveyou" in shape of 'heart' when executed. The impotant thing is that, the program should not show any kind of words related to it, i mean the program should not be understandable at the very first sight the user goes through the code. It will be gr8 if something more creative is...
12
2855
by: DannyB | last post by:
I'm just learning Python. I've created a simple coin flipper program - here is the code: #Coin flipper import random heads = 0 tails = 0 counter = 0
2
19354
Banfa
by: Banfa | last post by:
Posted by Banfa The previous tutorial discussed what programming is, what we are trying to achieve, the answer being a list of instructions constituting a valid program. Now we will discuss how we set about doing that. Every program starts with a specification, this may be a several hundred page document from your latest client or one small paragraph from your professor and pretty much anything in-between. The specification is very...
4
5325
by: slapsh0t11 | last post by:
Hello! I need help with a program that I believe I am nearly done with. However, there seems to be a few details that preclude me from success. Here is my assignment: Here is my class file (Sorts.java): import java.util.*; /**
0
9665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.