Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters
Register

Reply
 
LinkBack Thread Tools
Old 20.08.2005, 14:43   #1
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 35
Posts: 379
Downloads: 4
Uploads: 0
Reputation: 0 | 0
Default for code geeks :-)

Could somebody write a program on c++ (using only 'cout') which will print it's own source code ?
Reply With Quote
Old 20.08.2005, 16:36   #2
Профессор
 
Nikita's Avatar
 
Join Date: 01 2005
Location: Perm
Age: 40
Posts: 2,142
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

А ты мог бы показать множестнво которое содержит само себя ?
Reply With Quote
Old 24.09.2019, 16:39   #3
Self-taught coder
 
AvDav's Avatar
 
Join Date: 07 2004
Location: Eastern Europe
Age: 38
Posts: 3,551
Downloads: 22
Uploads: 0
Reputation: 228 | 4
Default

Code:
#include <string>
#include <fstream>
#include <iostream>

int main(int argc, char* argv[])
{
	std::string s;
	std::ifstream ifs(__FILE__);
	while(!ifs.fail()) {
		std::getline(ifs, s);
		std::cout << s << std::endl;
	}
	return 0;
}
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 10:01.


Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.