473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Program Showing its Source Code!!!

Hi!!! all
i got a program which shows its own source code as output but i m unable to understand what it is plz HELP and EXPLAIN it.

char *f="char*f=% c%s%c;main( ){printf( f,34,f,34, 10);}%c";
main()
{
printf(f,34, f,34,10);
}

Do we have any other way to create the program which shows its source code.
Jan 25 '07 #1
3 1269
Motoma
3,237 Expert 2GB
Hi!!! all
i got a program which shows its own source code as output but i m unable to understand what it is plz HELP and EXPLAIN it.

char *f="char*f=% c%s%c;main( ){printf( f,34,f,34, 10);}%c";
main()
{
printf(f,34, f,34,10);
}

Do we have any other way to create the program which shows its source code.

Okay, well, what is happening is that you are defining a character string which contains a tricky spot of code, as well as the entire body of your program. The program then prints the character string by playing around the the printf() function.
Jan 25 '07 #2
RedSon
5,000 Expert 4TB
You might want to consider looking up escape characters in your favorite c/c++ reference material. I think you'll find you have a few spots where you need to escape your punctuation marks.
Jan 25 '07 #3
HI:
i had to write this program for my prof afew days ago , and i wrote exactly what you have wrie here for my prof but unfortunatley he said that it isn't correct.please tell me why?!!!????
the other way to print the source code is to send argument to main function and
print the own file of program like this:
Expand|Select|Wrap|Line Numbers
  1. int main(char *argc ,int argv[1])
  2. {
  3. FILE *pt;
  4. pt=fopen("argv[0]","rb");
  5. printf("%p",*pt);
  6. }
  7.  
Jan 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Anthony Papillion II | last post by:
Hello Everyone, I have downloaded and installed mod_python and it doesn't seem to be working. I am hoping someone can give me some pointers as to what I am doing wrong. Here are the steps I've...
9
by: Michael Dekson | last post by:
Hello, Can I exe file made in Microsoft Visual C++ decompile into source code. If it is possibly please tell me how. Thanks
7
by: Prashanth Badabagni | last post by:
Hi , I'm Prashanth Badabagni .. I have and idea how a program prints it's own source code .. void main() { FILE *P; char *file,c; strcpy(file,__FILE__); p=fopen(file,"r");
17
by: wana | last post by:
I was reading through original source code of ping for some insight and was confused by unusual code. Entire listing available at: http://www.ping127001.com/pingpage/ping.html #include...
0
by: James Jenkins | last post by:
Hi - This auction will end in a very short time... Please take a look. It contains some very usefull .NET 2 code I have been working on a Bandwidth Monitoring program for 3 months now but am...
7
by: Tina | last post by:
In 1.1 I used to use a WebControlLibrary to hold code I didn't want to expose when I distributed a component. The code would compile to a separate dll and could not be viewed when used in a vs.net...
10
by: Tomás Ó hÉilidhe | last post by:
I'd post this on a gcc newsgroup but I'd be more productive talking to the wall. Anyway, let's say someone throws some source code at you for a particular program and says, "Just compile it, it...
21
by: mikhal80 | last post by:
Is it possible to write a program which would print out it's own source code, using C++?
33
by: Adeel Hasan Akbari | last post by:
Hi! I'm new to this field. Actually i'm a new programmer. And i've never worked in C. It is my humble request to you to provide me with the source code for Spaceball (the game in which there's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.