C Code Quoted in C Code
Nov. 14th, 2012 11:40 amThis is how you convert C source code (or any other ASCII text) into strings in C using Shell.
( Output )
make(1)
rules:all: verbatim.h verbatim.h: txt2cs.sed def.h sim.c printf '#define %s \\\n%s\n\n' >$*.tmp \ INDEF "$$(sed -f txt2cs.sed def.h)" printf '#define %s \\\n%s\n' >>$*.tmp \ INSIM "$$(sed -f txt2cs.sed sim.c)" mv $*.tmp $@ clean: -rm -fr verbatim.h *.tmp
sed(1)
script:s/\\/\\\\/g s/"/\\"/g s/ /\\t/g $!s/^\(.*\)$/ "\1\\n" \\/ $s/^\(.*\)$/ "\1\\n"/
( Output )