3 ms·
The Classic C Quine (2003)
- poetaster 5y agoAh. And read Feynman!
- moonchild 5y ago> The source code of this quine does not end with a newline That is undefined behaviour! (https://port70.net/~nsz/c/c11/n1570.html#J.2 https://port70.net/~nsz/c/c11/n1570.html#J.2)
- perl4ever 5y agohttps://pastebin.com/2MEKNGx5 https://pastebin.com/2MEKNGx5 This is an Excel macro that is self-aware: it only tries to print itself if it is a quine. It's sensitive to whitespace, so I provided the pastebin link above. Sub selfCheckingExcelQuine() s = "Sub selfCheckingExcelQuine()\ s = ~\ result = Replace(Replace(Replace(s, Chr(36), Chr(34)), Chr(92), vbCrLf), Chr(126), Chr(34) & s & Chr(34))\ \ If myText() = result Then\ Debug.Print result\ Else\ Debug.Print $Not a quine!$\ End If\End Sub\\Function myText()\ Dim p As VBProject: Set p = ThisWorkbook.VBProject\ Dim m As CodeModule: Set m = p.VBComponents(p.VBE.SelectedVBComponent.Name).CodeModule\ \ myText = m.Lines(1, m.CountOfLines)\End Function\" result = Replace(Replace(Replace(s, Chr(36), Chr(34)), Chr(92), vbCrLf), Chr(126), Chr(34) & s & Chr(34)) If myText() = result Then Debug.Print result Else Debug.Print "Not a quine!" End If End Sub Function myText() Dim p As VBProject: Set p = ThisWorkbook.VBProject Dim m As CodeModule: Set m = p.VBComponents(p.VBE.SelectedVBComponent.Name).CodeModule myText = m.Lines(1, m.CountOfLines) End Function