Top.Mail.Ru
The C++ Community's Journal -- Day
? ?
The C++ Community's Journal -- Day [entries|friends|calendar]
The C++ Community

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

Perl script for code formatting [06 Feb 2002|03:05am]
I wrote an extremely simple Perl script to make cpp code easy to post as HTML. It just escapes '<' and '>'. I am sure there are is other cpp syntax that doesn't translate to HTML well but the less than greater is all I can think of right now. Here is the script...


print "<pre><code>\n";
while(<>)
{
	s/</&lt;/g;
	s/>/&gt;/g;
	print $_;
}
print "</pre></code>\n";


One thing that is pretty cool is I used the script to escape itself. I called the script cppwebify.pl so the command line I used on a Win32 machine was



perl cppwebify.pl cppwebify.pl > output.html



I redirected the output from the script to the file output.html. I had to change the output to have the ampersand character by the way. I thought someone would be inspired by this to make a truly useful script for the cpp community to use for posting code. I wanted to use Javascript to do the formatting so you didn't have to have Perl but my Javascript is so rusty I couldn't do it without the book that I've left at school. My idea was to have webpage were you could paste cpp code into a text box then push a button to escape it for you, then you could copy and paste the escaped code to where you are writing a post. Maybe when I get a hold of my Javascript book I'll get it done.

9 comments|post comment

Help a Java programmer trying to do C? [06 Feb 2002|01:32pm]
Okay, I'm not much of a C programmer. Trying to compile sample code for MPCOS Smart Card Reader. I'm trying to compile it in Visual C++ 6 when the original code was written in Visual C++ 1.5! I get this error:

d:\mydocuments\mpcosfiles\gemdef.h(198) : error C2371: 'INT32' : redefinition; different basic types
c:\program files\microsoft visual studio\vc98\include\basetsd.h(33) : see declaration of 'INT32'

But when I comment out the line, I get this:
Read more...Collapse )
5 comments|post comment

A question on books ... [06 Feb 2002|11:47pm]
[ mood | Image curious ]

It's been a looong time since I studied, and a lot of the books I have are out of date.

Example: I have the 1991 edition of Robert Sedgewick's Algorithms in C++, and there's a much newer, bigger up-to-date yada yada 1998 third edition available (in two volumes, no less).

Does anyone who has the newer edition have any comments? Will it enhance my life, make me more attractive to the opposite sex, and so on?

4 comments|post comment

navigation
[ viewing | February 6th, 2002 ]
[ go | previous day|next day ]
Image