CrazyEngineers Forum
Navigation
Go Back   CrazyEngineers Forum > CE : Technical Discussions > Computer Science & IT Engineering
Forgot Password? Join Us!

CE - Ads
Reply
 
LinkBack (1) Thread Tools

  1 links from elsewhere to this Post. Click to view. #1
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
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: 11,301
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?
__________________
Founder & Administrator | CrazyEngineers® | admin{@}crazyengineers{dawt}com
About CE | Small Talk | Official Blog 'VoiCE' | Advertise On CE
The Big K's SuperBlogmt | Join CE! | Guide: How to post on CE
The_Big_K is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3
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,332
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
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
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
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
  #7
Old 23rd February 2010, 09:24 PM
CE - Regular Member
 
Join Date: 14th March 2009
I'm a Crazy Computer Engineer
Location: Pennsylvania, USA
Posts: 67
Default Re: A program that produces its source code as output

Quote:
Originally Posted by sriramchandrk View Post
There are 3 types of executable programs (interpreted(basic, perl) , compiled programs (c, pascal) & semi interpreted (java) )
...but there have been BASIC compilers and C interpreters. ???


-Will Dwinnell
Data Mining in MATLAB
Predictor is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8
Old 23rd February 2010, 09:42 PM
CE - Addict
CEoM December 2009
 
goyal420's Avatar
 
Join Date: 20th September 2009
I'm a Crazy Computer Engineer
Location: punjab
Posts: 925
Default Re: A program that produces its source code as output

Code:
import java.io.*;
class Source
{
public static void main(String args[])throws IOException
{
FileReader fr=new FileReader("Source.java");
int c;
while((c=fr.read())!=-1)
{
System.out.print((char)c);
}
}
}
__________________
Don't count every hour in the day. Make every hour in your day count
For some mind blowing tips visit my blog:- http://goyal1989.blogspot.com/
goyal420 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9
Old 24th February 2010, 02:46 PM
CE - Newbie
 
malardevi's Avatar
 
Join Date: 24th February 2010
I'm a Crazy Information Technology Engineer
Location: Kovilpatti
Posts: 1
Thumbs up Re: A program that produces its source code as output

Quote:
Originally Posted by prakash.athani View Post
Can anyone think about it and post replies?
I think try it by using the same file name in that program. open the same file read it and then print it. just try it.
malardevi is offline  
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 Off
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
Mouse programming in C prabhat kumar Computer Science & IT Engineering 9 13th February 2010 12:21 PM
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 02:01 AM
Code Coverage Testing - Related to White box testing Archana Kannouj Computer Science & IT Engineering 7 6th March 2008 02: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 01:47 PM.
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Member comments are owned by the poster. Copyright © 2005-2009 CrazyEngineers.com. All rights reserved.

CE - Ads

RadianceIITB

Advertise on CE