Code Comments
Programming Forum and web based access to our favorite programming groups.Dear All,
Apologies if this is OT or answered elsewhere, but I am looking for
some help.
I am using gawk to generate a C file as part of a build process, and
as such, the gawk script
does a lot of printing. Currently, I am using lots of print statements
(1 per line) to actually output the text. The body of my script looks
similar too:
print "int main(void) "
print "{"
...
print " return (0);"
print "}"
... and basically, I was wondering if there is a better way to produce
lots of static text ?
Many thanks,
James
Post Follow-up to this messageIn article <fe6eb44f.0411150757.5f62fd22@posting.google.com>,
James Pascoe <james@james-pascoe.com> wrote:
>Dear All,
>
>Apologies if this is OT or answered elsewhere, but I am looking for
>some help.
>
>I am using gawk to generate a C file as part of a build process, and
>as such, the gawk script
>does a lot of printing. Currently, I am using lots of print statements
>(1 per line) to actually output the text. The body of my script looks
>similar too:
>
>print "int main(void) "
>print "{"
>...
>print " return (0);"
>print "}"
>
>... and basically, I was wondering if there is a better way to produce
>lots of static text ?
The short answer is "not really". There's nothing really wrong with the
above, but sometimes I bunch them together, like this:
print "int main(void)\n{\n return (0);\n}"
at some cost in readability. Or, you could try:
OFS="\n"
print "int main(void)",
"{",
" return (0);",
"}"
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.