Skip to main content
2 of 4
added 9 characters in body
Conor O'Brien
  • 40.2k
  • 3
  • 91
  • 180

C++, 286 284 bytes

#include<iostream>
int main(){char a[]="#include<iostream>%sint main(){char a[]=%s%s%s;char b[]=%s%s%s%s;char c[]=%s%sn%s;char d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);return 0;}";char b[]="\"";char c[]="\n";char d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);return 0;}

I'm currently learning C++, and thought "Hey, I should make a quine in it to see how much I know!" 40 minutes later, I have this, a full 64 bytes shorter than the current one. I compiled it as:

g++ quine.cpp

Output and running:

C:\Users\Conor O'Brien\Documents\Programming\cpp
λ g++ quine.cpp && a
#include<iostream>
int main(){char a[]="#include <iostream>%sint main(){char a[]=%s%s%s;char b[]=%s%s%s%s;char c[]=%s%sn%s;char d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);return 0;}";char b[]="\"";char c[]="\n";char d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);return 0;}
Conor O'Brien
  • 40.2k
  • 3
  • 91
  • 180