Trouble using string functions

From: Gary Morris (gmorris61_at_carolina.rr.com)
Date: 10/31/04

  • Next message: Chris Croughton: "Re: Segmentation Fault..."
    Date: 31 Oct 2004 06:05:40 -0800
    
    

    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?


  • Next message: Chris Croughton: "Re: Segmentation Fault..."

    Relevant Pages

    • Re: Record Problem
      ... that is not correct - for multiple reasons. ... String is *NEVER* '1' unless string is declared to be a character of ... the details of list-directed output formatting are up to the compiler. ... fact, according to the standard, you can't assume anything about the ...
      (comp.lang.fortran)
    • Re: Get ASCII value for character when higher than 127
      ... The int values that are written to my textfile for the password file ... string GetASCIIString ... char timeString; ... strcat; ...
      (microsoft.public.vc.language)
    • Hmmm, Its Curious
      ... I thought it would be faster if I kept a pointer to the end of the string as it is built so that strcat() would not always have to find the end of the string as it gets longer and longer. ... To test this I called the vstrcatfunction with a list of pointers, then use the regular strcatfunction in a loop to build the same string. ... /* Implement a variardic string concatenation function which will */ ...
      (comp.lang.c)
    • Re: How to concatenate values
      ... Your strcat works fine in a standalone manner, ... failure in your strcat. ... concatenate them together, and put the result on the stack as a single ... % string, ...
      (comp.lang.postscript)
    • M$Inet control apparently SUCKS (or is it me) WTF????
      ... All I want to do is upload some files to ... Here is my code with URL, user, and pwd nuked for obvious reasons: ... Public Sub UploadFile(LocalPath As String, LocalFile As String, ... Dim lngElapse As Long ...
      (comp.lang.basic.visual.misc)