CrazyEngineers Forum
Navigation
Go Back   CrazyEngineers Forum > CE : Technical Discussions > Computer Science & IT Engineering


Advertisements
Reply
 
LinkBack (1) Thread Tools Display Modes

  1 links from elsewhere to this Post. Click to view. #1 (permalink)
Old 7th October 2008, 06:22 PM
CE - Regular Member
 
prakash.athani's Avatar
 
Join Date: 30th June 2008
I'm a Crazy Computer Science & IT Engineer
Posts: 53
Default A program that produces its source code as output

Can anyone think about it and post replies?
prakash.athani is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote


  #2 (permalink)
Old 8th October 2008, 08:58 AM
Good Administrator
 
The_Big_K's Avatar
 
Join Date: 26th November 2005
I'm a Crazy Electrical Engineer
Location: Terra-Firma
Posts: 8,546
Send a message via Yahoo to The_Big_K
Default Re: A program that produces its source code as output

No tries here? Where are our *crazy* computer engineers?
The_Big_K is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)
Old 8th October 2008, 09:09 AM
CE - Ambassador
 
sauravgoswami's Avatar
 
Join Date: 26th February 2008
I'm a Crazy Electronics Engineer
Location: India
Posts: 1,312
Send a message via Yahoo to sauravgoswami
Default Re: A program that produces its source code as output

well its possible to write a programme to generate source codes,and it is possible here too,but the challenge is to generate codes according to the need of the hour,say less memory space,more sturdy,preference of tools so.on...
__________________
Be HaPpY !!!! U can GET me @ saurav@crazyengineers.com
sauravgoswami is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)
Old 10th October 2008, 11:04 AM
CE - Regular Member
 
Join Date: 25th September 2008
I'm a Crazy CSE Engineer
Posts: 65
Default Re: A program that produces its source code as output

There are 3 types of executable programs (interpreted(basic, perl) , compiled programs (c, pascal) & semi interpreted (java) )

You can produce its own source code as output only in interpreted programs.

its possible for semi interpreted using a process called as decompilation but the output may not be exactly same as initial source.

It not possible for compiled program.

example for interpreted program using perl.
=========================

#!/usr/bin/perl

open(INFILE, $0);
while(<INFILE>)
{
print "$_";
}

=========================

Thanks & Regards
Sriram
sriramchandrk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)
Old 10th October 2008, 08:09 PM
CE - Apprentice
 
aashu_itdude's Avatar
 
Join Date: 25th June 2008
I'm a Crazy Information Technology Engineer
Location: gurgaon
Posts: 14
Default Re: A program that produces its source code as output

this c++ code reads the source file and displays the code as output. Its not a perfect code for this query but it can be further developed.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
void main()
{
clrscr();
int c=0;
char a[238];
ifstream fin("out.cpp"); //name of program
while(!fin.eof())
{
fin.read(a,238);
}
puts(a);
getch();
}
__________________
AASHU IT DUDE

Last edited by aashu_itdude; 10th October 2008 at 08:17 PM.
aashu_itdude is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)
Old 13th October 2008, 05:02 PM
CE - Newbie
 
Join Date: 13th October 2008
I'm a Crazy Software Engineer
Location: EGYPT
Posts: 6
Smile Re: A program that produces its source code as output

Assuming that the source file names test.cpp

Code:
#include<iostream>
#include<string>
using namespace std;

int main()
{
    freopen("test.cpp","rt",stdin);
    string g;
    while(getline(cin,g)&&cin)
    {
      cout<<g<<endl;
    }
    return 0;
}
emYth is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

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


LinkBacks (?)
LinkBack to this Thread: http://www.crazyengineers.com/forum/computer-science-engineering/5981-program-produces-its-source-code-output.html
Posted By For Type Date
A program that produces its source code as output - CrazyEngineers Forum This thread Refback 7th October 2008 06:50 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
C Challenge: Self-Printing Program The_Big_K Computer Science & IT Engineering 32 27th May 2009 09:52 PM
PC Tutorial: Parallel Port Interfacing Techniques - Part 2 xheavenlyx Computer Science & IT Engineering 26 11th January 2009 01:01 AM
Mouse programming in C prabhat kumar Computer Science & IT Engineering 6 28th April 2008 05:57 PM
Code Coverage Testing - Related to White box testing Archana Kannouj Computer Science & IT Engineering 7 6th March 2008 01:24 PM
Problem: Output of this C Code chaudharyssv Computer Science & IT Engineering 6 18th May 2007 11:34 AM


All times are GMT +6.5. The time now is 11:30 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0
Member comments are owned by the poster. Copyright © 2005-2009 CrazyEngineers.com. All rights reserved.

Advertisements