G
Gary Morris
Hi all,
I tried posting this through a free news server, but it
still has not appeared in Google, so if it turns up again
I apologize.
I hope someone can help me with this, or at least help me
find some information that will help me. If I were not at my
wit's end already, I wouldn't even ask. I'm used to doing all
of my programming in Windows, but now I have a task to
accomplish in UNIX/Linux using good old gcc.
Basically, what I have to do is parse a JavaScript file that
will ALWAYS have the following format:
************************************************
<!--
document.writeln('<TABLE BORDER="0" CELLPADDING="2">');
document.writeln(' <TR>');
....(many more lines all starting with "document.writeln('" )
document.writeln(' </TR>');
document.writeln('</TABLE>');
// -->
************************************************
It is auto-generated by another web site, and my job is to
get it to plain HTML format so that it can be linked to in an
email. What we want is for the end result to be:
************************************************
<TABLE BORDER="0" CELLPADDING="2">
<TR>
....(many more lines no longer with the "document.writeln('" )
</TR>
</TABLE>
************************************************
I have a good bit of it done, but I am getting stuck. Here is
the source I have so far in main:
{
int i, nc;
nc = 0;
for(int j = 1; j < 5; j++)
i = getchar();
while (i != EOF)
{
nc = nc + 1;
i = getchar();
if(i == '\n')
{
printf("%c", i);
for(int j = 1; j < 19; j++)
i = getchar();
}
else
{
printf("%c", i);
}
}
}
I am using redirction, i.e.: "prog<infile>outfile" to do this.
This code gets me close to what I need, but I still have the
remaining " '); " on the end of each string, which will not
do for obvious reasons. I tried reading into a string using
strcat(), which might do if I could just get it to work right,
for some reason my program will not run, no matter what I try
with strcat(). It will compile without any errors though.
I'm just not accustomed to using a language that does not
have an inherent "string" type. Everything is done with the
"char" type, and with the way some functions only want
pointers, etc, etc, well it's got me a bit confused and I've
spent WAY too much time on this already.
Can anyone help a fellow out?
I tried posting this through a free news server, but it
still has not appeared in Google, so if it turns up again
I apologize.
I hope someone can help me with this, or at least help me
find some information that will help me. If I were not at my
wit's end already, I wouldn't even ask. I'm used to doing all
of my programming in Windows, but now I have a task to
accomplish in UNIX/Linux using good old gcc.
Basically, what I have to do is parse a JavaScript file that
will ALWAYS have the following format:
************************************************
<!--
document.writeln('<TABLE BORDER="0" CELLPADDING="2">');
document.writeln(' <TR>');
....(many more lines all starting with "document.writeln('" )
document.writeln(' </TR>');
document.writeln('</TABLE>');
// -->
************************************************
It is auto-generated by another web site, and my job is to
get it to plain HTML format so that it can be linked to in an
email. What we want is for the end result to be:
************************************************
<TABLE BORDER="0" CELLPADDING="2">
<TR>
....(many more lines no longer with the "document.writeln('" )
</TR>
</TABLE>
************************************************
I have a good bit of it done, but I am getting stuck. Here is
the source I have so far in main:
{
int i, nc;
nc = 0;
for(int j = 1; j < 5; j++)
i = getchar();
while (i != EOF)
{
nc = nc + 1;
i = getchar();
if(i == '\n')
{
printf("%c", i);
for(int j = 1; j < 19; j++)
i = getchar();
}
else
{
printf("%c", i);
}
}
}
I am using redirction, i.e.: "prog<infile>outfile" to do this.
This code gets me close to what I need, but I still have the
remaining " '); " on the end of each string, which will not
do for obvious reasons. I tried reading into a string using
strcat(), which might do if I could just get it to work right,
for some reason my program will not run, no matter what I try
with strcat(). It will compile without any errors though.
I'm just not accustomed to using a language that does not
have an inherent "string" type. Everything is done with the
"char" type, and with the way some functions only want
pointers, etc, etc, well it's got me a bit confused and I've
spent WAY too much time on this already.
Can anyone help a fellow out?