473,602 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Program to remove C comments (long signature)

This program is long. I don't really want to bore everyone with the
details, but it handles wierd cases like:

/\
* this is a comment *\
/

#define FOO ??/* this is not a comment */

char *a = /* this is a comment "\*/"this is a string"/*" another comment */;

I intend this program to be an example of how to write a kind of state
machine, not really an example of tight coding, but any comments would
be welcome.

Thanks,

-- James
--
/*
* cstripc: A C program to strip comments from C files.
* Usage:
* cstripc [file [...]]
* cstripc [-t]
*
* The '-t' options is used for testing. It prints some pointers to strings
* that are interlaced with comment characters.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*************** **/
/**** GLOBALS ****/
/*************** **/

static const char *progname;
static int debug_flag;

/*************** *******/
/**** MAIN PROGRAM ****/
/*************** *******/

static void print_usage(voi d);
static void print_test(void );

static FILE * open_input_file (const char *filename);
static void close_input_fil e(FILE *infile);
static void parse_input_fil e(FILE *infile);

int
main(int argc, char *argv[])
{
progname = argv[0];
if (progname == 0) {
progname = "cstripc";
}

while (argc > 1) {

if ((*argv[1] != '-') || (strcmp(argv[1], "-") == 0)) {
break;
}

if (strcmp(argv[1], "-t") == 0) {
print_test();
exit(0);
} else if (strcmp(argv[1], "-d") == 0) {
debug_flag = 1;
} else {
fprintf(stderr, "%s: Unrecognized option '%s'\n",
progname, argv[1]);
print_usage();
exit(EXIT_FAILU RE);
}

--argc;
++argv;
}

if (argc <= 1) {
parse_input_fil e(stdin);
exit(0);
}

while (argc > 1) {
FILE *infile;

parse_input_fil e(infile = open_input_file (argv[1]));
close_input_fil e(infile);

--argc;
++argv;
}
}

/*************** ***********/
/**** PRINT USAGE/TEST ****/
/*************** ***********/

static const char *usage_string =
"%s: A C program to strip comments from C files.\n"
"Usage:\n"
" %s [file [...]]\n"
" %s [-t]\n"
"\n"
"The '-t' options is used for testing. It prints some pointers to strings\n"
"that are interlaced with comment characters.\n"
;

static void
print_usage(voi d)
{
fprintf(stderr, usage_string, progname, progname, progname);
}

static const char *a;
static const char *b;
static const char *c;

static void
print_test(void )
{
if (a) puts(a);
if (b) puts(b);
if (c) puts(c);
}

/*************** *************** */
/**** OPEN/CLOSE INPUT FILE ****/
/*************** *************** */

static const char *input_file_nam e;

static FILE *
open_input_file (const char *filename)
{
FILE *infile;

input_file_name = filename;

if (filename == 0) {
return 0;
}

if (strcmp(filenam e, "-") == 0) {
return stdin;
}

infile = fopen(filename, "r");
if (infile == 0) {
fprintf(stderr, "%s: Could not open '%s' for reading.\n",
progname, filename);
}

return infile;
}

static void
close_input_fil e(FILE *infile)
{
if (infile) {
if (infile != stdin) {
if (fclose(infile) == EOF)
fprintf(stderr, "%s, Could not close '%s'.\n",
progname, input_file_name );
} else {
clearerr(stdin) ;
}
}
}

/*************** ***********/
/**** PARSE INPUT FILE ****/
/*************** ***********/

typedef struct scan_state scan_state;
typedef struct scan_context scan_context;

struct scan_context {
scan_state *ss;
char *sbuf;
unsigned sbufsz;
unsigned sbufcnt;
};

struct scan_state {
scan_state *(*scan)(scan_c ontext *ctx, int input);
const char *name;
};

static scan_context initial_scan_co ntext;

static void
parse_input_fil e(FILE *infile)
{
int c;
scan_context ctx;

if (infile == 0) {
return;
}

ctx = initial_scan_co ntext;

while ((c = fgetc(infile)) != EOF) {
if (debug_flag) {
fprintf(stderr, "%s\n", ctx.ss->name);
}
ctx.ss = ctx.ss->scan(&ctx, c);
}
}

/*************** ********/
/**** STATE MACHINE ****/
/*************** ********/

/*
*
*************** *************** *************** *************** ***************
* Assume input is a syntactically correct C program.
*
* The basic algorithm is:
* Scan character by character:
* Treat trigraphs as a single character.
* If the sequence does not start a comment, emit the sequence.
* Otherwise,
* Scan character by character:
* Treat trigraphs as a single character.
* Treat the sequence '\\' '\n' as no character.
* If the sequence does not end a comment, continue consuming.
* Otherwise, emit a space, and loop back to top.
*************** *************** *************** *************** ***************
*
*/

#define SCAN_STATE_DEFI NE(name) \
static scan_state * name##_func(sca n_context *ctx, int input); \
static scan_state name##_state = { name##_func, #name }

SCAN_STATE_DEFI NE(normal);
SCAN_STATE_DEFI NE(normal_maybe _tri_1);
SCAN_STATE_DEFI NE(normal_maybe _tri_2);
SCAN_STATE_DEFI NE(string);
SCAN_STATE_DEFI NE(string_maybe _tri_1);
SCAN_STATE_DEFI NE(string_maybe _tri_2);
SCAN_STATE_DEFI NE(string_maybe _splice);
SCAN_STATE_DEFI NE(char);
SCAN_STATE_DEFI NE(char_maybe_t ri_1);
SCAN_STATE_DEFI NE(char_maybe_t ri_2);
SCAN_STATE_DEFI NE(char_maybe_s plice);
SCAN_STATE_DEFI NE(slash);
SCAN_STATE_DEFI NE(slash_maybe_ tri_1);
SCAN_STATE_DEFI NE(slash_maybe_ tri_2);
SCAN_STATE_DEFI NE(slash_maybe_ splice);
SCAN_STATE_DEFI NE(slashslash);
SCAN_STATE_DEFI NE(slashslash_m aybe_tri_1);
SCAN_STATE_DEFI NE(slashslash_m aybe_tri_2);
SCAN_STATE_DEFI NE(slashslash_m aybe_splice);
SCAN_STATE_DEFI NE(slashsplat);
SCAN_STATE_DEFI NE(slashsplat_s plat);
SCAN_STATE_DEFI NE(slashsplat_s plat_maybe_tri_ 1);
SCAN_STATE_DEFI NE(slashsplat_s plat_maybe_tri_ 2);
SCAN_STATE_DEFI NE(slashsplat_s plat_maybe_spli ce);

#define SCAN_STATE(name ) (&name##_stat e)

static scan_context initial_scan_co ntext = { SCAN_STATE(norm al), 0, 0, 0 };

static void sbuf_append_cha r(scan_context *ctx, int c);
static void sbuf_append_str ing(scan_contex t *ctx, char *s);
static void sbuf_clear(scan _context *ctx);
static void sbuf_emit(scan_ context *ctx);

static scan_state *
normal_func(sca n_context *ctx, int input)
{
switch (input) {
case '?': sbuf_emit(ctx);
sbuf_append_cha r(ctx, input);
return SCAN_STATE(norm al_maybe_tri_1) ;
case '"': sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(stri ng);
case '\'': sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(char );
case '/': sbuf_emit(ctx);
sbuf_append_cha r(ctx, input);
return SCAN_STATE(slas h);
default: sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(norm al);
}
}

static scan_state *
normal_maybe_tr i_1_func(scan_c ontext *ctx, int input)
{
switch (input) {
case '?': sbuf_append_cha r(ctx, input);
return SCAN_STATE(norm al_maybe_tri_2) ;
default: sbuf_emit(ctx);
return SCAN_STATE(norm al)->scan(ctx, input);
}
}

static scan_state *
normal_maybe_tr i_2_func(scan_c ontext *ctx, int input)
{
switch (input) {
case '?': putchar(input);
return SCAN_STATE(norm al_maybe_tri_2) ;
case '=':
case '(':
case ')':
case '<':
case '>':
case '!':
case '\'':
case '-':
case '/': sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(norm al);
default: sbuf_emit(ctx);
return SCAN_STATE(norm al)->scan(ctx, input);
}
}

static scan_state *
string_func(sca n_context *ctx, int input)
{
switch (input) {
case '?': sbuf_emit(ctx);
sbuf_append_cha r(ctx, input);
return SCAN_STATE(stri ng_maybe_tri_1) ;
case '"': sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(norm al);
case '\\': sbuf_emit(ctx);
sbuf_append_cha r(ctx, input);
return SCAN_STATE(stri ng_maybe_splice );
default: sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(stri ng);
}
}

static scan_state *
string_maybe_tr i_1_func(scan_c ontext *ctx, int input)
{
switch (input) {
case '?': sbuf_append_cha r(ctx, input);
return SCAN_STATE(stri ng_maybe_tri_2) ;
default: sbuf_emit(ctx);
return SCAN_STATE(stri ng)->scan(ctx, input);
}
}

static scan_state *
string_maybe_tr i_2_func(scan_c ontext *ctx, int input)
{
switch (input) {
case '?': putchar(input);
return SCAN_STATE(stri ng_maybe_tri_2) ;
case '/': sbuf_append_car (ctx, input);
return SCAN_STATE(stri ng_maybe_splice );
case '=':
case '(':
case ')':
case '<':
case '>':
case '!':
case '\'':
case '-': sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(stri ng);
default: sbuf_emit(ctx);
return SCAN_STATE(stri ng)->scan(ctx, input);
}
}

static scan_state *
string_maybe_sp lice_func(scan_ context *ctx, int input)
{
switch (input) {
case '\n':
default: sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(stri ng);
}
}

static scan_state *
char_func(scan_ context *ctx, int input)
{
switch (input) {
case '?': sbuf_emit(ctx);
sbuf_append_cha r(ctx, input);
return SCAN_STATE(char _maybe_tri_1);
case '\'': sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(norm al);
case '\\': sbuf_emit(ctx);
sbuf_append_cha r(ctx, input);
return SCAN_STATE(char _maybe_splice);
default: sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(char );
}
}

static scan_state *
char_maybe_tri_ 1_func(scan_con text *ctx, int input)
{
switch (input) {
case '?': sbuf_append_cha r(ctx, input);
return SCAN_STATE(char _maybe_tri_2);
default: sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(char )->scan(ctx, input);
}
}

static scan_state *
char_maybe_tri_ 2_func(scan_con text *ctx, int input)
{
switch (input) {
case '?': putchar(input);
return SCAN_STATE(char _maybe_tri_2);
case '/': sbuf_append_cha r(ctx, input);
return SCAN_STATE(char _maybe_splice);
case '=':
case '(':
case ')':
case '<':
case '>':
case '!':
case '\'':
case '-': sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(char );
default: sbuf_emit(ctx);
return SCAN_STATE(char )->scan(ctx, input);
}
}

static scan_state *
char_maybe_spli ce_func(scan_co ntext *ctx, int input)
{
switch (input) {
case '\n':
default: sbuf_emit(ctx);
putchar(input);
return SCAN_STATE(char );
}
}

static scan_state *
slash_func(scan _context *ctx, int input)
{
switch (input) {
case '?': sbuf_append_cha r(ctx, input);
return SCAN_STATE(slas h_maybe_tri_1);
case '\\': sbuf_append_cha r(ctx, input);
return SCAN_STATE(slas h_maybe_splice) ;
case '/': sbuf_clear(ctx) ;
return SCAN_STATE(slas hslash);
case '*': sbuf_clear(ctx) ;
return SCAN_STATE(slas hsplat);
default: sbuf_emit(ctx);
return SCAN_STATE(norm al)->scan(ctx, input);
}
}

static scan_state *
slash_maybe_tri _1_func(scan_co ntext *ctx, int input)
{
switch (input) {
case '?': return SCAN_STATE(slas h_maybe_tri_2);
default: sbuf_emit(ctx);
return SCAN_STATE(norm al)->scan(ctx, input);
}
}

static scan_state *
slash_maybe_tri _2_func(scan_co ntext *ctx, int input)
{
switch (input) {
case '?': sbuf_emit(ctx);
sbuf_append_str ing(ctx, "??");
return SCAN_STATE(norm al_maybe_tri_2) ;
case '/': sbuf_append_cha r(ctx, '?');
sbuf_append_cha r(ctx, input);
return SCAN_STATE(slas h_maybe_splice) ;
case '=':
case '(':
case ')':
case '<':
case '>':
case '!':
case '\'':
case '-': sbuf_append_cha r(ctx, '?');
sbuf_append_cha r(ctx, input);
sbuf_emit(ctx);
return SCAN_STATE(norm al);
default: sbuf_append_cha r(ctx, '?');
sbuf_emit(ctx);
return SCAN_STATE(norm al)->scan(ctx, input);
}
}

static scan_state *
slash_maybe_spl ice_func(scan_c ontext *ctx, int input)
{
switch (input) {
case '\n': sbuf_append_cha r(ctx, input);
return SCAN_STATE(slas h);
default: sbuf_emit(ctx);
return SCAN_STATE(norm al)->scan(ctx, input);
}
}

static scan_state *
slashslash_func (scan_context *ctx, int input)
{
/* UNUSED */ ctx = ctx;
switch (input) {
case '?': return SCAN_STATE(slas hslash_maybe_tr i_1);
case '\\': return SCAN_STATE(slas hslash_maybe_sp lice);
case '\n': putchar(' ');
putchar(input);
return SCAN_STATE(norm al);
default: return SCAN_STATE(slas hslash);
}
}

static scan_state *
slashslash_mayb e_tri_1_func(sc an_context *ctx, int input)
{
switch (input) {
case '?': return SCAN_STATE(slas hslash_maybe_tr i_2);
default: return SCAN_STATE(slas hslash)->scan(ctx, input);
}
}

static scan_state *
slashslash_mayb e_tri_2_func(sc an_context *ctx, int input)
{
switch (input) {
case '?': return SCAN_STATE(slas hslash_maybe_tr i_2);
case '/': return SCAN_STATE(slas hslash_maybe_sp lice);
case '=':
case '(':
case ')':
case '<':
case '>':
case '!':
case '\'':
case '-': return SCAN_STATE(slas hslash);
default: return SCAN_STATE(slas hslash)->scan(ctx, input);
}
}

static scan_state *
slashslash_mayb e_splice_func(s can_context *ctx, int input)
{
switch (input) {
case '\n': return SCAN_STATE(slas hslash);
default: return SCAN_STATE(slas hslash)->scan(ctx, input);
}
}

static scan_state *
slashsplat_func (scan_context *ctx, int input)
{
/* UNUSED */ ctx = ctx;
switch (input) {
case '*': return SCAN_STATE(slas hsplat_splat);
default: return SCAN_STATE(slas hsplat);
}
}

static scan_state *
slashsplat_spla t_func(scan_con text *ctx, int input)
{
switch (input) {
case '?': return SCAN_STATE(slas hsplat_splat_ma ybe_tri_1);
case '\\': return SCAN_STATE(slas hsplat_splat_ma ybe_splice);
case '/': putchar(' ');
return SCAN_STATE(norm al);
default: return SCAN_STATE(slas hsplat)->scan(ctx, input);
}
}

static scan_state *
slashsplat_spla t_maybe_tri_1_f unc(scan_contex t *ctx, int input)
{
switch (input) {
case '?': return SCAN_STATE(slas hsplat_splat_ma ybe_tri_2);
default: return SCAN_STATE(slas hsplat)->scan(ctx, input);
}
}

static scan_state *
slashsplat_spla t_maybe_tri_2_f unc(scan_contex t *ctx, int input)
{
switch (input) {
case '/': return SCAN_STATE(slas hsplat_splat_ma ybe_splice);
case '=':
case '(':
case ')':
case '<':
case '>':
case '!':
case '\'':
case '-': return SCAN_STATE(slas hsplat);
default: return SCAN_STATE(slas hsplat)->scan(ctx, input);
}
}

static scan_state *
slashsplat_spla t_maybe_splice_ func(scan_conte xt *ctx, int input)
{
switch (input) {
case '\n': return SCAN_STATE(slas hsplat_splat);
default: return SCAN_STATE(slas hsplat)->scan(ctx, input);
}
}

/*************** **********/
/**** BUFFER HANDLING ****/
/*************** **********/

static void
sbuf_append_cha r(scan_context *ctx, int c)
{
if (ctx->sbuf == 0) {
ctx->sbuf = malloc(ctx->sbufsz = 128);
} else if (ctx->sbufcnt == ctx->sbufsz) {
char *p = realloc(ctx->sbuf, ctx->sbufsz *= 2);
if (p == 0) {
fprintf(stderr, "%s: memory allocation failure\n", progname);
exit(EXIT_FAILU RE);
}
ctx->sbuf = p;
}

ctx->sbuf[ctx->sbufcnt++] = c;
ctx->sbuf[ctx->sbufcnt] = '\0';
}

static void
sbuf_append_str ing(scan_contex t *ctx, char *s)
{
while (*s != '\0') {
sbuf_append_cha r(ctx, *s++);
}
}

static void
sbuf_clear(scan _context *ctx)
{
ctx->sbufcnt = 0;
if (ctx->sbuf) {
ctx->sbuf[ctx->sbufcnt] = '\0';
}
}

static void
sbuf_emit(scan_ context *ctx)
{
if (ctx->sbuf == 0 || ctx->sbufcnt == 0) {
return;
}

printf("%s", ctx->sbuf);
sbuf_clear(ctx) ;
}

/*************** *****/
/**** TEST CASES ****/
/*************** *****/

/* a comment */
/\
* a comment split */
/\
\
* a comment split twice */
/*
block comment
*/
/* comment, trailing delimiter split *\
/
/* comment, trailing delimiter split twice *\
\
/
/* comment, trailing delimiter split once, and again by trigraph *\
??/
/

static const char *a = /* comment in code line "*/"Hello, "/**/"World!";
static const char *b = /\
* comment on code line split */ "Hello, " /\
\
* comment on code line split twice */ "World!";

#define FOO ??/* this does not start a comment */

#if defined(__STDC_ _) && (__STDC__ == 1)
#if defined(__STD_V ERSION__) && (__STD_VERSION_ _ >= 199901L)
//*** MORE TEST CASES ***//
/\
/ // comment split
/\
\
/ // comment split twice
static const char *c = // // comment on code line
"Hello, " /\
/ // comment on code line split
"World!" /\
\
/ // comment on code line split twice.
;

#define BAR ??// this does not start a comment

// This is a // comment \
on two lines

#else
static const char *c = "STDC without STD_VERSION";
#endif
#endif
Nov 13 '05 #1
11 9459
James Hu wrote:
This program is long. I don't really want to bore everyone with the
details, but it handles wierd cases like: ^^^^^
<rant>
Weird how this word is one of the most misspelled words I have ever come
across :) .
</rant>
#define FOO ??/* this is not a comment */


Why is this not a comment? I have always wondered about the behaviour of
comments in "defines". And if it really becomes part of the define, isn't
ommiting it here not the same as ommiting it in all the places where FOO
would be replaced?

Thanks for the info,

--
Martijn
http://www.sereneconcepts.nl
Nov 13 '05 #2
Martijn <su************ *********@hotno filtermail.com> scribbled the following:
James Hu wrote:
This program is long. I don't really want to bore everyone with the
details, but it handles wierd cases like: ^^^^^
<rant>
Weird how this word is one of the most misspelled words I have ever come
across :) .
</rant>

#define FOO ??/* this is not a comment */

Why is this not a comment? I have always wondered about the behaviour of
comments in "defines". And if it really becomes part of the define, isn't
ommiting it here not the same as ommiting it in all the places where FOO
would be replaced?


It's not a comment because the ??/ forms a trigraph, expanding into a \
(backslash).

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A computer program does what you tell it to do, not what you want it to do."
- Anon
Nov 13 '05 #3
"Martijn" <su************ *********@hotNO FILTERmail.com> wrote:
James Hu wrote: <snip>
#define FOO ??/* this is not a comment */


Why is this not a comment? I have always wondered about the behaviour of
comments in "defines".


The problem is not to have a comment after a #define directive, the
"problem" is that ??/ is a trigraph sequence that will be replaced
by a backslash by the C preprocessor /prior/ to comment stripping.
And if it really becomes part of the define, isn't
ommiting it here not the same as ommiting it in all the places where FOO
would be replaced?
Mu. Comments will be replaced by a single blank each, /before/ the
#define directive is handled by the preprocessor. (Otherwise it would
be impossible to 'comment out' preprocessor directives.)

For more info about translation phases I suggest to read section
5.1.1.2 in the C99 Standard.
Thanks for the info,


HTH
Regards
--
Irrwahn
(ir*******@free net.de)
Nov 13 '05 #4
James Hu <jx*@despammed. com> wrote in message news:<Qc******* *************@c omcast.com>...
This program is long. I don't really want to bore everyone with the
details, but it handles wierd cases like:


That should be "weird".

Found a bug, a cut and paste error. Discovery of the bug and the fix
will be left as an exercise to the interested reader. :-)

-- James
--
Hint: char_maybe_tri_ 1_func
Nov 13 '05 #5
Martijn wrote:
James Hu wrote:
This program is long. I don't really want to bore everyone with the
details, but it handles wierd cases like:


^^^^^
<rant>
Weird how this word is one of the most misspelled words I have ever come
across :) .
</rant>


Because the rule says I before E, except after C. The rhyme did
acknowledge "weird" and another word as exceptions but I forget that
part of it.
#define FOO ??/* this is not a comment */

Why is this not a comment? I have always wondered about the behaviour of
comments in "defines". And if it really becomes part of the define, isn't
ommiting it here not the same as ommiting it in all the places where FOO
would be replaced?


It's not because it's in a #define. The following is a comment:

#define FOO 123 /* This is a comment */

Sean

Nov 13 '05 #6
Fao, Sean wrote:
Because the rule says I before E, except after C.


$ grep -ci '[^c]ei' /usr/dict/words
764
Nov 13 '05 #7
On 12 Nov 2003 18:53:31 -0800, jx*@despammed.c om (James Hu) wrote:
James Hu <jx*@despammed. com> wrote in message news:<Qc******* *************@c omcast.com>...
This program is long. I don't really want to bore everyone with the
details, but it handles wierd cases like:


That should be "weird".

Found a bug, a cut and paste error. Discovery of the bug and the fix
will be left as an exercise to the interested reader. :-)

-- James

Just recently I was reading someone who said that cut and paste should
be disallowed in program editors :-)

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Nov 13 '05 #8
Jeremy Yallop wrote:
Fao, Sean wrote:
Because the rule says I before E, except after C.

$ grep -ci '[^c]ei' /usr/dict/words
764


I hate English :-).

Nov 13 '05 #9
>> <rant>
Weird how this word is one of the most misspelled words I have ever
come across :) .
</rant>


Because the rule says I before E, except after C. The rhyme did
acknowledge "weird" and another word as exceptions but I forget that
part of it.


leisure? (and any derivative?)

Anyway, thanks everybody for the help! I suspected the ??/ was the gotcha
in this comment :) I wasn't even aware of this kind of escape characters...

Thanks!

--
Martijn
http://www.sereneconcepts.nl
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1681
by: G Patel | last post by:
I wrote the following program to remove C89 type comments from stdin and send it to stdout (as per exercise in K&R2) and it works but I was hoping more experienced programmer would critique the layout/style/etc. Any comments will be helpful. Thank you. /* **************************************************** C89/90 COMMENT REMOVER
4
2106
by: KenFehling | last post by:
Hello. I am wondering if there exists a piece of software that takes multiple .js files that are nicely indented and commented and create one big tightly packed .js file. I'm hoping the one file would be less of a burden for the user's browser to download. I guess the final code output by this hypothetical program could maybe even just be on one long line unless that would create problems. Maybe there is some kind of optimal line...
4
1978
by: Rico | last post by:
Hello, I'd like to change a field from an Autonum to a Long data type using DAO. I knwo how to set the attribute, but don't know how to remove it. Any ideas? Thanks!
0
1368
by: Travis Oliphant | last post by:
This post is to gather feedback from the wider community on PEP 357. It is nearing the acceptance stage and has previously been discussed on python-dev. This is a chance for the wider Python community to comment on the proposal. You will find the PEP attached PEP: 357
11
1573
by: srenusa | last post by:
hi, I am quite new to c++ programming and I would need some help with my college assigment: write a program which reads input c++ file and removes commentary. The commentary can be oneline(//) and block commentary(/**/. The name of the file is read from the command line. use functions and global variables if neccesary. here is my code. Thanks in advance #include <fstream>
23
2248
by: mike3 | last post by:
Hi. I seem to have made some progress on finding that bug in my program. I deactivated everything in the bignum package that was used except for the returning of BigFloat objects. I even crippled all the constructors. So now all the operations and constructors that were used do is just return BigFloats but no memory is actually accessed at any point, nor is any allocated. However, when I reenable those parts of the constructor that...
3
419
by: cs | last post by:
Hi, I'm new to C and would appreciate any feedback on the following program, asplit, which splits a file into 2 new files, putting a certain number of lines in the first file, and all the rest in the second file. Any comments as to non-portability, stylistic infelicities, outright bugs or anything else would be very much appreciated.
69
5556
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same signature for the method (i.e., as below, int Square (int)). Here is an example to show that feature. Note class "UnAwareClass" has its methods Square and Cuber called by a class DelegateClass. This is because these methods in UnAwareClass have the...
9
1914
by: xiao | last post by:
It always dumped when I tried to run it... But it compiles OK. What I want to do is to do a test: Read information from a .dat file and then write it to another file. The original DAT file is like this : (very simple..........) 010001010110001101010101010101010101010101 #include<stdio.h>
0
8404
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.