Re: c question

2010-04-23 Thread Eitan Adler
- use a matrix is faster than use a linked list? For what? For insertion and deletion no - linked list is faster. For sequential access they are the same speed (forgetting look-ahead caching). For random access matrix is faster. ___

Re: c question

2010-04-23 Thread Joerg Sonnenberger
On Fri, Apr 23, 2010 at 06:18:46PM +0300, Eitan Adler wrote: - use a matrix is faster than use a linked list? For what? For insertion and deletion no - linked list is faster. For sequential access they are the same speed (forgetting look-ahead caching). For random access matrix is faster.

Re: c question

2010-04-23 Thread Pieter de Goeje
On Friday 23 April 2010 17:40:12 Joerg Sonnenberger wrote: On Fri, Apr 23, 2010 at 06:18:46PM +0300, Eitan Adler wrote: - use a matrix is faster than use a linked list? For what? For insertion and deletion no - linked list is faster. For sequential access they are the same speed

c question

2010-04-09 Thread Leinier Cruz Salfran
hello all i want to know your oppinions about this: - use a matrix is faster than use a linked list? example: char *szColumnName[10]; unsigned short iColumnAge[10]; struct _llList { struct _llList *prev, *next; char szName[64]; unsigned short iAge; };

Re: c question

2010-04-09 Thread Alexander Churanov
2010/4/9 Leinier Cruz Salfran salfrancl.lis...@gmail.com - use a matrix is faster than use a linked list? example: char *szColumnName[10]; unsigned short iColumnAge[10]; struct _llList { struct _llList *prev, *next; char szName[64]; unsigned short iAge; }; Leinier , This

Re: c question

2010-04-09 Thread Leinier Cruz Salfran
On Fri, Apr 9, 2010 at 10:52 AM, Alexander Churanov alexanderchura...@gmail.com wrote: 2010/4/9 Leinier Cruz Salfran salfrancl.lis...@gmail.com - use a matrix is faster than use a linked list? example: char *szColumnName[10]; unsigned short iColumnAge[10]; struct _llList {  struct

Re: c question

2010-04-09 Thread KAYVEN RIESE
On Fri, 9 Apr 2010, Leinier Cruz Salfran wrote: hello all i want to know your oppinions about this: - use a matrix is faster than use a linked list? yes. example: char *szColumnName[10]; unsigned short iColumnAge[10]; struct _llList { struct _llList *prev, *next; char szName[64];

Re: c question: *printf'ing arrays

2009-07-08 Thread Alexander Best
thx for all the great help guys. cheers, alex Carlos A. M. dos Santos schrieb am 2009-07-02: 2009/7/2 Dag-Erling Smørgrav d...@des.no: Alexander Best alexbes...@math.uni-muenster.de writes:     for (i=0; i sizeof(hdr-nintendo_logo); i++)         fprintf(stderr, %x, hdr-nintendo_logo[i]);

Re: c question: *printf'ing arrays

2009-07-04 Thread Giorgos Keramidas
On Tue, 30 Jun 2009 20:21:03 +0200 (CEST), Alexander Best alexbes...@math.uni-muenster.de wrote: thanks. now the output gets redirected using . i'm quite new to programming under unix. sorry for the inconvenience. so i guess there is no really easy way to output an inhomogeneous struct to

Re: c question: *printf'ing arrays

2009-07-04 Thread Giorgos Keramidas
On Wed, 01 Jul 2009 00:06:05 +0200 (CEST), Alexander Best alexbes...@math.uni-muenster.de wrote: thanks for all the help. i decided to take the pill and coded all the fprintfs by hand. here's the result. usually i'd stick to a higher level languag, but i need C's inline assembly support:

Re: c question: *printf'ing arrays

2009-07-04 Thread Igor Mozolevsky
2009/7/4 Giorgos Keramidas keram...@ceid.upatras.gr: [snip] s/0x%/%#.2hh/g -- Igor ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to

Re: c question: *printf'ing arrays

2009-07-02 Thread Dag-Erling Smørgrav
Alexander Best alexbes...@math.uni-muenster.de writes: for (i=0; i sizeof(hdr-nintendo_logo); i++) fprintf(stderr, %x, hdr-nintendo_logo[i]); What will this print if nintendo_logo is { 0x01, 0x02, 0x03, 0x04 }? DES -- Dag-Erling Smørgrav - d...@des.no

Re: c question: *printf'ing arrays

2009-07-02 Thread Carlos A. M. dos Santos
2009/7/2 Dag-Erling Smørgrav d...@des.no: Alexander Best alexbes...@math.uni-muenster.de writes:     for (i=0; i sizeof(hdr-nintendo_logo); i++)         fprintf(stderr, %x, hdr-nintendo_logo[i]); What will this print if nintendo_logo is { 0x01, 0x02, 0x03, 0x04 }? Good catch. It will print

Re: c question: *printf'ing arrays

2009-07-01 Thread Carlos A. M. dos Santos
On Tue, Jun 30, 2009 at 7:54 PM, Alfred Perlsteinalf...@freebsd.org wrote: Hey Alex, People frown on macros, but this could be a good one: #define SPRINT(f, fmt) \        do {\                for (_i = 0; _i sizeof(f)/sizeof(f[0]); i++) \                        printf(fmt, f[i]); \      

Re: c question: *printf'ing arrays

2009-07-01 Thread Carlos A. M. dos Santos
On Tue, Jun 30, 2009 at 7:06 PM, Alexander Bestalexbes...@math.uni-muenster.de wrote: thanks for all the help. i decided to take the pill and coded all the fprintfs by hand. here's the result. usually i'd stick to a higher level languag, but i need C's inline assembly support:    struct

c question: *printf'ing arrays

2009-06-30 Thread Alexander Best
hi there, i need to output the header of a file to stdout. the header looks like this: struct Header { u_int8_t rom_entry[4]; u_int8_t nintendo_logo[156]; u_char game_title[12]; u_char game_code[4]; u_char maker_code[2]; u_int8_t fixed_val;

Re: c question: *printf'ing arrays

2009-06-30 Thread Tom Evans
On Tue, 2009-06-30 at 18:12 +0200, Alexander Best wrote: hi there, i need to output the header of a file to stdout. the header looks like this: struct Header { u_int8_t rom_entry[4]; u_int8_t nintendo_logo[156]; u_char game_title[12]; u_char

Re: c question: *printf'ing arrays

2009-06-30 Thread Alexander Best
thanks. but that simply dumps the contents of the struct to stdout. but since most of the struct's contents aren't ascii the output isn't really of much use. cheers. Tom Evans schrieb am 2009-06-30: On Tue, 2009-06-30 at 18:12 +0200, Alexander Best wrote: hi there, i need to output the

Re: c question: *printf'ing arrays

2009-06-30 Thread Alexander Best
that works, but i really want to have a pretty output to stdout. i guess i have to stick with printf and use `for (i=0; i sizeof(XXX); i++)` for each array in the struct. just thought i could avoid it. btw. `./my-program | hexdump` works, but if i do `./my-program output` output is being

Re: c question: *printf'ing arrays

2009-06-30 Thread Igor Mozolevsky
2009/6/30 Alexander Best alexbes...@math.uni-muenster.de: that works, but i really want to have a pretty output to stdout. i guess i have to stick with printf and use `for (i=0; i sizeof(XXX); i++)` for each array in the struct. just thought i could avoid it. btw. `./my-program | hexdump`

Re: c question: *printf'ing arrays

2009-06-30 Thread Alexander Best
should be stdout. struct Header *hdr = rom; int new_fd = open(/dev/stdout, O_RDWR); printf(SIZE: %d\n,sizeof(*hdr)); write(new_fd, hdr, sizeof(*hdr)); close(new_fd); Igor Mozolevsky schrieb am 2009-06-30: 2009/6/30 Alexander Best alexbes...@math.uni-muenster.de: that works, but i really

Re: c question: *printf'ing arrays

2009-06-30 Thread Rick C. Petty
On Tue, Jun 30, 2009 at 08:03:21PM +0200, Alexander Best wrote: should be stdout. struct Header *hdr = rom; int new_fd = open(/dev/stdout, O_RDWR); printf(SIZE: %d\n,sizeof(*hdr)); write(new_fd, hdr, sizeof(*hdr)); close(new_fd); Why are you reopening stdout? It should already be

Re: c question: *printf'ing arrays

2009-06-30 Thread Igor Mozolevsky
2009/6/30 Alexander Best alexbes...@math.uni-muenster.de: thanks. but that simply dumps the contents of the struct to stdout. but since most of the struct's contents aren't ascii the output isn't really of much use. How about ./your-program | hexdump ? -- Igor

Re: c question: *printf'ing arrays

2009-06-30 Thread Igor Mozolevsky
2009/6/30 Alexander Best alexbes...@math.uni-muenster.de: should be stdout. struct Header *hdr = rom; int new_fd = open(/dev/stdout, O_RDWR); printf(SIZE: %d\n,sizeof(*hdr)); write(new_fd, hdr, sizeof(*hdr)); close(new_fd); You should really be checking what open returns, opening

Re: c question: *printf'ing arrays

2009-06-30 Thread Alexander Best
thanks. now the output gets redirected using . i'm quite new to programming under unix. sorry for the inconvenience. so i guess there is no really easy way to output an inhomogeneous struct to stdout without using a loop to output each array contained in the struct. cheers. Rick C. Petty

Re: c question: *printf'ing arrays

2009-06-30 Thread Rick C. Petty
On Tue, Jun 30, 2009 at 08:21:03PM +0200, Alexander Best wrote: thanks. now the output gets redirected using . i'm quite new to programming under unix. sorry for the inconvenience. No problem; we all had to learn sometime. But what I suggested should work for every platform that adheres to

Re: c question: *printf'ing arrays

2009-06-30 Thread Alfred Perlstein
Hey Alex, People frown on macros, but this could be a good one: #define SPRINT(f, fmt) \ do {\ for (_i = 0; _i sizeof(f)/sizeof(f[0]); i++) \ printf(fmt, f[i]); \ }while(0) :D This should allow you to point to any _array_ and print each

Re: c question: *printf'ing arrays

2009-06-30 Thread Alexander Best
wow. thanks. that's looking really nice. i'll change my sources tomorrow after a good dose of sleep. ;) alex Alfred Perlstein schrieb am 2009-07-01: Hey Alex, People frown on macros, but this could be a good one: #define SPRINT(f, fmt) \ do {\ for (_i = 0; _i

Re: Port-related C++ question

2001-04-29 Thread Dima Dorfman
Jos Backus [EMAIL PROTECTED] writes: On Sat, Apr 28, 2001 at 09:32:51PM -0700, Dima Dorfman wrote: Jos Backus [EMAIL PROTECTED] writes: void stdin(const Config config); -=== line 99 `stdin' is a global variable which, surprisingly enough, refers to the standard input stream.

Re: Port-related C++ question

2001-04-29 Thread Peter Seebach
In message [EMAIL PROTECTED], Jos Backus writes: Yeah, I am just puzzled as to how this can build at all on other platforms (Linux?), unless they don't define this variable. Many of them probably have it as an external object, not a #define. I'm still not sure the code makes any sense. -s To

Re: Port-related C++ question

2001-04-29 Thread Warner Losh
In message [EMAIL PROTECTED] Peter Seebach writes: : In message [EMAIL PROTECTED], Jos Backus writes: : Yeah, I am just puzzled as to how this can build at all on other platforms : (Linux?), unless they don't define this variable. : : Many of them probably have it as an external object, not a

Port-related C++ question

2001-04-28 Thread Jos Backus
[Apologies if this is the wrong list for this type of question.] I am trying to create a port for a commandline-accessible database tool, but I am running into the following problem (on RELENG_4 as of today): === Building for dbtool-1.3 c++ -DPACKAGE=\dbtool\ -DVERSION=\1.3\ -DSTDC_HEADERS=1

Re: Port-related C++ question

2001-04-28 Thread Dima Dorfman
Jos Backus [EMAIL PROTECTED] writes: void stdin(const Config config); -=== line 99 `stdin' is a global variable which, surprisingly enough, refers to the standard input stream. Don't name a function after it and your problem should go away. To Unsubscribe: send mail to [EMAIL PROTECTED]

Re: Port-related C++ question

2001-04-28 Thread Warner Losh
In message [EMAIL PROTECTED] Jos Backus writes: : dbtool.h:99: declaration of `__sF' as array of references : void stdin(const Config config); -=== line 99 stdin is #defined to be __sF[0]. Warner To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of

Re: Port-related C++ question

2001-04-28 Thread Jos Backus
On Sat, Apr 28, 2001 at 09:32:51PM -0700, Dima Dorfman wrote: Jos Backus [EMAIL PROTECTED] writes: void stdin(const Config config); -=== line 99 `stdin' is a global variable which, surprisingly enough, refers to the standard input stream. Don't name a function after it and your

Re: X11/C++ question

1999-11-03 Thread Warner Losh
In message [EMAIL PROTECTED] Chuck Robey writes: : Does anyone (anyone, that is, who's coded X11 applications) know how you : handle X11 callbacks to C++ object methods? OI_add_event(3OI) :-) Warner To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body

Re: X11/C++ question

1999-11-03 Thread Chuck Robey
On Wed, 3 Nov 1999, Warner Losh wrote: In message [EMAIL PROTECTED] Chuck Robey writes: : Does anyone (anyone, that is, who's coded X11 applications) know how you : handle X11 callbacks to C++ object methods? OI_add_event(3OI) :-) Uhhh? I've long since got the answer I wanted, but this

Re: X11/C++ question

1999-11-03 Thread Warner Losh
In message [EMAIL PROTECTED] Chuck Robey writes: : Uhhh? I've long since got the answer I wanted, but this seems a complete : mystery, so I'll bite, what's a OI_add_event? From some package? Can't : find a man page on it. OI was a native C++ toolkit that had a nice interface and was ported to

Re: X11/C++ question

1999-11-03 Thread Thomas David Rivers
In message [EMAIL PROTECTED] Chuck Robey writes: : Uhhh? I've long since got the answer I wanted, but this seems a complete : mystery, so I'll bite, what's a OI_add_event? From some package? Can't : find a man page on it. OI was a native C++ toolkit that had a nice interface and was

Re: X11/C++ question

1999-10-27 Thread Alexey Zelkin
hi, Does anyone (anyone, that is, who's coded X11 applications) know how you handle X11 callbacks to C++ object methods? Thanks, TDR If you mean Xt (and possibly Motif) - the answer is "very carefully." TDR The Xt callbacks are C based, so you typically can't directly call a TDR

Re: X11/C++ question

1999-10-27 Thread Ville-Pertti Keinonen
[EMAIL PROTECTED] (Chuck Robey) writes: Boy, I sure wish Java compiled and ran natively. I'd stop using C++ forever. gcc-2.95.1 + libgcj already works, at least for simple programs. On FreeBSD 3.x programs seem to work as long as you use statically linked libraries (shared libraries cause

Re: X11/C++ question

1999-10-27 Thread Wes Peters
Chuck Robey wrote: On Tue, 26 Oct 1999 [EMAIL PROTECTED] wrote: Thomas David Rivers writes: If you mean Xt (and possibly Motif) - the answer is "very carefully." [...] You're approach would probably work, but there's an easier way. See topic 28 in the Xt FAQ.

Re: X11/C++ question

1999-10-27 Thread Chuck Robey
On Wed, 27 Oct 1999, Wes Peters wrote: Chuck Robey wrote: On Tue, 26 Oct 1999 [EMAIL PROTECTED] wrote: Thomas David Rivers writes: If you mean Xt (and possibly Motif) - the answer is "very carefully." [...] You're approach would probably work, but there's an easier

X11/C++ question

1999-10-26 Thread Chuck Robey
Does anyone (anyone, that is, who's coded X11 applications) know how you handle X11 callbacks to C++ object methods? Thanks, Chuck Robey| Interests include C programming, Electronics, 213 Lakeside Dr.

Re: X11/C++ question

1999-10-26 Thread Thomas David Rivers
Does anyone (anyone, that is, who's coded X11 applications) know how you handle X11 callbacks to C++ object methods? Thanks, If you mean Xt (and possibly Motif) - the answer is "very carefully." The Xt callbacks are C based, so you typically can't directly call a C++ method. But,

Re: X11/C++ question

1999-10-26 Thread Daniel O'Connor
On 27-Oct-99 Thomas David Rivers wrote: If you mean Xt (and possibly Motif) - the answer is "very carefully." Or you could just use a toolkit written for C++ or with C++ shims already.. ie Qt or GTK.. --- Daniel O'Connor software and network engineer for Genesis Software -

Re: X11/C++ question

1999-10-26 Thread Daniel O'Connor
On 27-Oct-99 Thomas David Rivers wrote: And, wasn't there a freely available C++ shim for motif floating around at one time? I don't know.. My X experience begins and ends with Tk :) (Don't like Motif either ;) --- Daniel O'Connor software and network engineer for Genesis Software -

Re: X11/C++ question

1999-10-26 Thread Chris Costello
On Tue, Oct 26, 1999, Thomas David Rivers wrote: extern "C" { void callback_function(arg1) void *arg1; { /* Call the method */ myclass::mymethod(arg1); As far as I've seen, you can't directly call a class method without an

Re: X11/C++ question

1999-10-26 Thread tbuswell
Thomas David Rivers writes: If you mean Xt (and possibly Motif) - the answer is "very carefully." [...] You're approach would probably work, but there's an easier way. See topic 28 in the Xt FAQ. ftp://ftp.x.org/contrib/faqs/FAQ-Xt It's not name mangling causing problems, it's lack of

Re: X11/C++ question

1999-10-26 Thread Chuck Robey
On Tue, 26 Oct 1999, Thomas David Rivers wrote: Does anyone (anyone, that is, who's coded X11 applications) know how you handle X11 callbacks to C++ object methods? Thanks, If you mean Xt (and possibly Motif) - the answer is "very carefully." The Xt callbacks are C based, so

Re: X11/C++ question

1999-10-26 Thread Chuck Robey
On Wed, 27 Oct 1999, Daniel O'Connor wrote: On 27-Oct-99 Thomas David Rivers wrote: If you mean Xt (and possibly Motif) - the answer is "very carefully." Or you could just use a toolkit written for C++ or with C++ shims already.. ie Qt or GTK.. If I wanted to just get X11 done, I

Re: X11/C++ question

1999-10-26 Thread Thomas David Rivers
Then you just stick a C wrapper function around every C++ callback you want to register, is that it? Seems a bit inelegant, but I suppose, if the ultimate test of elegance is that "it's the only one that works", then it's perhaps elegant *enough*. I believe someone posted a better

Re: X11/C++ question

1999-10-26 Thread Chuck Robey
On Tue, 26 Oct 1999 [EMAIL PROTECTED] wrote: Thomas David Rivers writes: If you mean Xt (and possibly Motif) - the answer is "very carefully." [...] You're approach would probably work, but there's an easier way. See topic 28 in the Xt FAQ. ftp://ftp.x.org/contrib/faqs/FAQ-Xt

Re: X11/C++ question

1999-10-26 Thread Bakul Shah
Allow me add something to what the FAQ-Xt says. I find it more convenient to immediately call a non-static function as shown below (using a slightly modified example from the FAQ). class Icon { public: Icon(Widget*); private: static void

Re: X11/C++ question

1999-10-26 Thread Chuck Robey
On Tue, 26 Oct 1999, Bakul Shah wrote: Allow me add something to what the FAQ-Xt says. I find it more convenient to immediately call a non-static function as shown below (using a slightly modified example from the FAQ). Just got out of the shower, where I was wondering why they didn't

Re: X11/C++ question

1999-10-26 Thread Brian Fundakowski Feldman
On Tue, 26 Oct 1999, Chris Costello wrote: On Tue, Oct 26, 1999, Thomas David Rivers wrote: extern "C" { void callback_function(arg1) void *arg1; { /* Call the method */ myclass::mymethod(arg1); As far as I've seen,