Qbasicnews.com

Full Version: C Style commenting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Wrong...

# = shift + "3"..
// = two "/" presses..
' = one "'" press..

/* */= two shift presses and two "/" presses...


Here's a question:

What are the possible quotes in C? Just a '?
Depends on the context, the function, and the compiler. ' and " are both used depending on these things.
Quote:Wrong...

# = shift + "3"..
// = two "/" presses..
' = one "'" press..

/* */= two shift presses and two "/" presses...

Wrong about what? I still say # is "less" typing than //, because you can hold down shift as you hit the 3, in one motion, whereas // requires two presses and releases.

Anonymous

heh if aan argument breaks out over this... Tongue

have some shots you two Big Grin

man im wasted
For me, quickly tapping // is easy peasy, but using Shift + 3 requires a brief moment of premeditation and then a hand stretch. // is faster for me. Big Grin
Quote:
Agamemnus Wrote:Wrong...

# = shift + "3"..
// = two "/" presses..
' = one "'" press..

/* */= two shift presses and two "/" presses...

Wrong about what? I still say # is "less" typing than //, because you can hold down shift as you hit the 3, in one motion, whereas // requires two presses and releases.
Not for me. A double tap of the slash is perfect.
It depends on your keyboard # is right above the shift key for me(shift 3 is a pound sign for me).

It would be nice if you could 'mod' the QB ide to add things easily, I know you can(looks at the person/people who changed some text to make it look like their own compiler).
Get the source code for the IDE (good luck :o ), program a few operations...like if you tap SHIFT-R, it could add a REM.
But who cares, eh?
Quote:For me, quickly tapping // is easy peasy, but using Shift + 3 requires a brief moment of premeditation and then a hand stretch. // is faster for me. Big Grin
Exactly my thoughts
Oracle,

At first glance, your challenge to remove comments from C code looks relatively easy. I haven't needed to use C in about 6 years, so I dug up some of my old C programs and took a look.

The first question in my mind is: Why would you want to strip the comments from a C program anyway? Is this a practical requirement or just an exercise?

While scanning over 100 C programs, I couldn't find the // prefix for on-line comments. I only found the leading /* and the trailing */ even if the comment was only on a single line. Are you sure the // option exists on all versions of C?

Anyway, my review of the programs came up with the following sticky considerations:

1) It's possible that /* or */ or // could appear inside of a quoted string, and some quoted strings are delimited by double quotes (") and others by single quotes ('). So every time the program finds one of these supposed comment delimeters, it would have to do several scans to make sure that they were not found within quoted strings, which of course would have to be ignored. This is not as easy as it sounds. Watch out, 'cause the comments themselves could contain either of the quotes or even embedded delimiters themselves.

2) An absolute "must" requirement is that the C source code has already been successfully compiled. You can appreciate that if the source code has errors, then the comment removing program will go bananas. In any event, the program will have to detect certain fatal errors, like a multi-line comment that has no subsequent */ terminator.

3) Another "must" is to successfully compile the new uncommented code and then compare the object code to the original. If they don't match, then the comment remover doesn't work.

Since you mentioned "C style" programs, perhaps the program will have to ask the user up front what comment delimeters he wants to use. Maybe this can be on a little parameter file as input.

In summary, if you have a practical use for this program, I'd be interested in taking a crack at it. If it's just an exercise, I'll pass.
*****
Pages: 1 2 3 4 5