String handling in .txt file.

From: David Flick (df_at_nospamme.com)
Date: 01/31/05


Date: Mon, 31 Jan 2005 11:43:48 GMT

It has been nearly two decades since I used C. I am therefor a bit out of
touch. A program we have been using since 1998 that was written in a mix
of C and C++ now needs to be modified. It appears the original code may
have been developed with some compiler specific syntax. At present I am
down to just a few syntax errors and am hoping for the final nudge. This
is what I am trying to do.
Each morning we need to hand carry a disk with information and import the
message stream into MS Outlook. From there the Inbox is exported to a DOS
comma delimited file (msg.txt). We then run the routine against the comma
delimited file which produces another .txt file (msghdr.txt) to print the
message headers.
These are the points I am stuck on:
1) fprintf(opfile,"\t List for ");
fprintf(opfile, "%d/%d/%d.\n", d.da_mon, d.da_day, d.da_year);

Should send a literal and system date to the output file. The date
formatting does not matter so long as it is a commonly recognizable date
format. I would think it a simple matter to get a system date, but my
reference books take me on a really long trek to develop date classes and
so on.

2) fprintf(stdprn,"\f\t\t Message List (Page #%d) for %d/%d/%d.\r\n\n",
page, d.da_mon, d.da_day, d.da_year);

Syntax check produces an error pointing to stdprn. I just need a plain
text stream to a printer on LPT1.

3)while (!kbhit());

Syntax check objects to kbhit. It is not necessary to wait for a key
press, but it would be a nice to know thing for the future.

4) Occasionally in the download stream there are two embedded ASCII 26
characters that cause the routine to abort. When that happens I have been
going in with Notepad to manually delete the offending characters before
proceeding. How would I go about introducing error checking for non-
printable characters. The pattern always appears as NNNN<ASCII 26><ASCII
26> at the end of each message in the body of the .txt file.

I have managed to get around all the other problems from the original code.
We do not have the developer's notes from 1998. It appears he may have
used a Borland compiler, but again we do not have the original compiler to
simply try running the code against it as is. Just the .cpp and .exe
files.

TIA

Dave



Relevant Pages

  • Re: String handling in .txt file.
    ... > have been developed with some compiler specific syntax. ... I don't think you have a syntax issue, ... > text stream to a printer on LPT1. ... > characters that cause the routine to abort. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: snprintf for fprintf
    ... as its syntax is ... u can use how many characters u want to ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • Re: Tcl Switch case
    ... My thesis is that there could be a good reason to change the syntax of ... a command, and one reason is to align with what the byte compiler ... bug has persisted for 15 years, but has never kept anyone from writing ...
    (comp.lang.tcl)
  • Re: Handling error/status messages by interface to C++ programs
    ... about how to design a compiler, please tell me where I can find ... exceptions for managing the error detection is rather a bad idea. ... I have to say I have seen a simple example of an object-oriented parser design in some book (unfortunately I forgot ... It would trigger user notification and do recover housekeeping like reseting the current syntax row's token stack because one wants to continue parsing and detect any other errors w/o aborting. ...
    (comp.object)
  • Re: Syntax (was: Perfrom Thru
    ... "This statement has violated the limits of this compiler" ... these are syntax violations in the Standard's definition of them. ... > whether the problem is a compiler limitation or it is a syntax error, ... >> Then not "source violates the SYNTAX rules of the Standard" ...
    (comp.lang.cobol)