- #1
Lojzek
- 249
- 1
I would like to write a C program that writes itself to the screen (without reading from disk).
My idea is to assign text to a string S, split it into two parts S1 and S2 and then write each part twice. If S1 is made equal to program part before text definition and S2 equal to program part after, then the program would write S1S1S2S2, which would be equal to the whole program.
However I don't know how to put a text into the string S. I tried to use strcpy, but it does not work if the text is too long for a single line. Is there a way to store a several line long text into a string without spliting the text (the whole text should be written inside a single "").
My idea is to assign text to a string S, split it into two parts S1 and S2 and then write each part twice. If S1 is made equal to program part before text definition and S2 equal to program part after, then the program would write S1S1S2S2, which would be equal to the whole program.
However I don't know how to put a text into the string S. I tried to use strcpy, but it does not work if the text is too long for a single line. Is there a way to store a several line long text into a string without spliting the text (the whole text should be written inside a single "").