Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6341547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:03:23+00:00 2026-05-24T20:03:23+00:00

A few years back I was thinking about ways to make a program that

  • 0

A few years back I was thinking about ways to make a program that prints its own source code and I came up with these two approaches:

  • the program prints the .c or .cpp file based upon the executable name (app1 prints app1.cpp). but this will fail in case the .cpp file is located somewhere else.
  • the program makes “clever” use of strings (I forgot the source code of this), and prints itself.

Is there any other algorithm a program can use to print its own source code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:03:29+00:00Added an answer on May 24, 2026 at 8:03 pm

    I think your two cases cover all the options. Case (1) covers cases of the form “load the program source from an external device,” while case (2) covers cases of the form “generate the program source programmatically.” You could of course consider a hybrid approach like “read the first half of the program from a file and then generate the second half programmatically,” but this doesn’t seem any different from what you described above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember a few years back, I used a program that was capable of
I remember seeing a poster a few years back that had a nice break
I am getting back into a bit more .NET after a few-years of not
A few years ago, I read a book that described how you could override
A few years ago, it was proven that PRIMES is in P . Are
Today I was thinking about a Python project I wrote about a year back
In an application I wrote a few years back I use function SystemParametersInfo with
We have a Java/Swing client that's been around for quite a few years. When
A few years back, another clever programmer set up a VB.NET service to print
A few years back I worked in a Sybase/Delphi environment, using the BDE to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.