473,387 Members | 1,574 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,387 software developers and data experts.

how to print source code from binary

Hi All,

I need to write a program that will print source code of its source file.
Assume that after building the binary i will delete the source file.

Thanks,
Akshobhya
Nov 23 '06 #1
5 2388
sivadhas2006
142 100+
Hi All,

I need to write a program that will print source code of its source file.
Assume that after building the binary i will delete the source file.

Thanks,
Akshobhya
Hi Akshobhya,

This may satisfy your need.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. char *program = "#include <stdio.h>%cchar *program = %c%s%c;%cint main()%c{%c%cprintf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);%c%creturn 0;%c}%c";
  4. int main()
  5. {
  6.         printf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);
  7.         return 0;
  8. }
  9.  
  10.  
  11.  
Regards,
M.Sivadhas.
Nov 24 '06 #2
Hi Akshobhya,

This may satisfy your need.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. char *program = "#include <stdio.h>%cchar *program = %c%s%c;%cint main()%c{%c%cprintf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);%c%creturn 0;%c}%c";
  4. int main()
  5. {
  6.         printf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);
  7.         return 0;
  8. }
  9.  
  10.  
  11.  
Regards,
M.Sivadhas.
Hi Sivadhas,

Thank you very much its very good interesting programming skill.
Send me such puzzles if you find some time.

Thanks,
Aks
Nov 24 '06 #3
Hi Sivadhas,

Thank you very much its very good interesting programming skill.
Send me such puzzles if you find some time.

Thanks,
Aks
would some one please explain me this program and its process (to print the source code)?
Jan 15 '07 #4
would some one please explain me this program and its process (to print the source code)?
The source is included in the printf statements.
Jan 16 '07 #5
Soujiro
35
Yes.. good... you guys know of any dynamic approach using just GNU library.. C perhaps..
Jan 16 '07 #6

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

Similar topics

0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
8
by: Lucas | last post by:
I need print a file in binary mode . f = f.open('python.jpg','rb') bytes = f.read() f.close() print(bytes) I can't get any binary code.
12
by: waterdriven | last post by:
Hello; I am a newbie. A homework assignment was assigned and I am having trouble getting started. The assignment reads: Write a program to print out the binary value of a 16 bit number.
1
by: Sin Jeong-hun | last post by:
It looked like that I can print a number in hexadecimal format with Console.Write, but I couldn't find how to print in binary format. I mean 000...0001 for 1, 000...0010 for 2 and so on. I wrote...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.