Re: C programming, checking for ^C

2011-02-22 Thread Steven Ayre
And don't forget to call usleep() or something similar for a short period of time if you're not doing anything in the loop except waiting for Ctrl-C. How short depends on how responsive you want it to be. Otherwise you'll end up with a loop that's constantly looping going round and round and eating

Re: C programming, checking for ^C

2011-02-21 Thread Boyd Stephen Smith Jr.
In , T o n g wrote: >I need to check for ^C in an endless loop that doesn't do any stdio. >How can I do that? > >Back in DOS days, I used to use kbhit() from CONIO.H, which checks for >currently available keystrokes. Is there similar things under Linux gcc? Ctrl+C will generally result in your pro

Re: C programming question

2010-04-16 Thread Stephen Powell
On Fri, 16 Apr 2010 14:13:36 -0400 (EDT), Boyd Stephen Smith Jr. wrote: > Stephen Powell wrote: >> I'm going to be filing a bug report against parted for (a) miscalculating >> the starting block of the implicit partition on an ldl (Linux Disk Layout) >> formatted disk on the s390 architecture when

Re: C programming question

2010-04-16 Thread Boyd Stephen Smith Jr.
In <1876691691.55741.1271378240260.javamail.r...@md01.wow.synacor.com>, Stephen Powell wrote: >I'm going to be filing a bug report against parted for (a) miscalculating > the starting block of the implicit partition on an ldl (Linux Disk Layout) > formatted disk on the s390 architecture when the b

Re: C programming question

2010-04-16 Thread Stephen Powell
On Thu, 15 Apr 2010 21:09:43 -0400 (EDT), Stephen Powell wrote: > On Thu, 15 Apr 2010 20:43:21 -0400 (EDT), Ron Johnson wrote: >> On 2010-04-15 19:37, Stephen Powell wrote: >>> >>> I'm going to be filing a bug report against parted for (a) miscalculating >>> the starting block of the implicit part

Re: C programming question

2010-04-15 Thread Stephen Powell
On Thu, 15 Apr 2010 20:43:21 -0400 (EDT), Ron Johnson wrote: > On 2010-04-15 19:37, Stephen Powell wrote: >> >> I'm going to be filing a bug report against parted for (a) miscalculating >> the starting block of the implicit partition on an ldl (Linux Disk Layout) >> formatted disk on the s390 arch

Re: C programming question

2010-04-15 Thread Ron Johnson
On 2010-04-15 19:37, Stephen Powell wrote: [snip] I'm going to be filing a bug report against parted for (a) miscalculating the starting block of the implicit partition on an ldl (Linux Disk Layout) formatted disk on the s390 architecture when the block size is other than 4096, and (b) no supp

Re: C programming question

2010-04-15 Thread Stephen Powell
On Thu, 15 Apr 2010 17:39:42 -0400 (EDT), Boyd Stephen Smith Jr. wrote: > Stephen Powell wrote: >> In short, I need to >> (a) declare "cms_label" as a based structure, > > (above; trimmmed) >> >> (b) >> declare a pointer variable called "cms_ptr" and associate it with the >> "cms_label" structure,

Re: C programming question

2010-04-15 Thread Boyd Stephen Smith Jr.
On Thursday 15 April 2010 13:56:00 Stephen Powell wrote: > On Wed, 14 Apr 2010 23:10:55 -0400 (EDT), Boyd Stephen Smith Jr. wrote: > > On Tuesday 13 April 2010 17:16:03 Stephen Powell wrote: > >> What I need to do is to have two structures overlay each other; so that > >> they occupy the same stor

Re: C programming question

2010-04-15 Thread Stephen Powell
On Wed, 14 Apr 2010 23:10:55 -0400 (EDT), Boyd Stephen Smith Jr. wrote: > On Tuesday 13 April 2010 17:16:03 Stephen Powell wrote: >> What I need to do is to have two structures overlay each other; so that >> they occupy the same storage. To be specific, here is a structure which >> describes the

Re: C programming question

2010-04-14 Thread Boyd Stephen Smith Jr.
On Tuesday 13 April 2010 17:16:03 Stephen Powell wrote: > What I need to do is to have two structures overlay each other; so that > they occupy the same storage. To be specific, here is a structure which > describes the volume label for an OS-formatted disk: > > struct __attribute__ ((packed))

Re: C programming question

2010-04-14 Thread Paul E Condon
On 20100414_123342, Ron Johnson wrote: > On 2010-04-14 09:31, Paul E Condon wrote: > [snip] > > > >non-obvious --- to the point that there was an open contest with > >prizes awarded for the most obfuscated example of C code. The prizes > >went to the code for which the judges were most surprised on

Re: C programming question [OT]

2010-04-14 Thread thib
Ron Johnson wrote: [snip] http://www1.us.ioccc.org/main.html I guess they got bored looking at normal production C code... Sometimes, I find the code there even more impressive: http://underhanded.xcott.com/ It's even more restricted, and not so pointless. Hiding in plain sight, beaut

Re: C programming question

2010-04-14 Thread John Hasler
Ron Johnson writes: > Unions have been in C for at least 20 years; probably since the Early > Days. Unions are in the first edition of K&R. -- John Hasler -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian

Re: C programming question

2010-04-14 Thread Ron Johnson
On 2010-04-14 09:31, Paul E Condon wrote: [snip] non-obvious --- to the point that there was an open contest with prizes awarded for the most obfuscated example of C code. The prizes went to the code for which the judges were most surprised on seeing it run after they read the code and tried to

Re: C programming question

2010-04-14 Thread Hugo Vanwoerkom
Stephen Powell wrote: I realize that this is not a C forum, per se, but this is a Debian-specific C question. I am trying to add support to the parted utility for CMS-formatted disks on the s390 architecture. The source code is written in C, of course. But I am not a C programmer. I can spell

Re: C programming question

2010-04-14 Thread Paul E Condon
On 20100413_193540, Robert Baron wrote: > What a great little learning project. > > My suggestion is to work out a simpler version of what you are trying to do: > > typedef struct { > unsigned short rec_type; > long data; > } type1; > > typedef struct { > unsigned short rec_type; >

Re: C programming question

2010-04-13 Thread Robert Baron
What a great little learning project. My suggestion is to work out a simpler version of what you are trying to do: typedef struct { unsigned short rec_type; long data; } type1; typedef struct { unsigned short rec_type; char data[4]; } type2; . some_type *chunk_of_mem; long

RE: C programming question

2010-04-13 Thread Mike Viau
> Tue, 13 Apr 2010 17:29:51 -0500 wrote: > > On 2010-04-13 17:16, Stephen Powell wrote: > > I realize that this is not a C forum, per se, but this is a Debian-specific > > C question. I am trying to add support to the parted utility for > > CMS-formatted > [snip] > > > > I know how to do this

Re: C programming question

2010-04-13 Thread Ron Johnson
On 2010-04-13 17:16, Stephen Powell wrote: I realize that this is not a C forum, per se, but this is a Debian-specific C question. I am trying to add support to the parted utility for CMS-formatted [snip] I know how to do this in PL/I, but despite having spent the last two hours paging throug

Re: C++ programming: keeping count of data items read from file [OT] [OOT] (off-off-topic)

2008-05-08 Thread s. keeling
Mark Allums <[EMAIL PROTECTED]>: > Mark Allums wrote: > > Rich Healey wrote: > > > Mark Allums wrote: > > >> 1. You might want to learn PERL or Python or Ruby, and do it there. > > > FWIW, this is very easy to do in Python. > > > PSFWIW: Satan uses Ruby. > > > > I thought that Beelzebub

Re: C++ programming: keeping count of data items read from file [OT] [OOT] (off-off-topic)

2008-05-06 Thread Mark Allums
Mark Allums wrote: > Rich Healey wrote: > > Mark Allums wrote: > >> 1. You might want to learn PERL or Python or Ruby, and do it there. > > FWIW, this is very easy to do in Python. > > PSFWIW: Satan uses Ruby. > > :) > > I thought that Beelzebub used IronPython. > I mean, given the connection

Re: C++ programming: keeping count of data items read from file [OT] [OOT] (off-off-topic)

2008-05-06 Thread Mark Allums
Rich Healey wrote: > Mark Allums wrote: >> 1. You might want to learn PERL or Python or Ruby, and do it there. > FWIW, this is very easy to do in Python. > PSFWIW: Satan uses Ruby. :) I thought that Beelzebub used IronPython. -- Mark Allums -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread Rich Healey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mark Allums wrote: > H.S. wrote: >> Hello, >> >> In a C++ program I am reading a data file for later processing and >> computations. While reading that data file, I want to keep track of >> data items (doubles) read. >> >> The data file is just a text

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread H.S.
Mark Allums wrote: Not directly helpful, but some suggestions: 1. You might want to learn PERL or Python or Ruby, and do it there. hmm .. not sure how this will pan out in the long run, but for now, I am trying to keep it all within one program. 2. If it has to be C++, learn enough PERL t

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread Hal Vaughan
On Tuesday 06 May 2008, H.S. wrote: > Ron Johnson wrote: > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > On 05/06/08 11:42, H.S. wrote: > >> Hello, > >> > >> In a C++ program I am reading a data file for later processing and > >> computations. While reading that data file, I want to k

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread Mark Allums
H.S. wrote: Hello, In a C++ program I am reading a data file for later processing and computations. While reading that data file, I want to keep track of data items (doubles) read. The data file is just a text file with N lines with C doubles in each line (N and C are known a priori). For n

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread Jordi Gutiérrez Hermoso
On 06/05/2008, H.S. <[EMAIL PROTECTED]> wrote: > In a C++ program I am reading a data file for later processing and > computations. While reading that data file, I want to keep track of data > items (doubles) read. Use std::list and other standard data structures. It's C++. Don't use C arrays, ug

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread Robert Baron
On Tue, May 6, 2008 at 12:57 PM, Ron Johnson <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 05/06/08 11:42, H.S. wrote: > > Hello, > > > > In a C++ program I am reading a data file for later processing and > > computations. While reading that data file, I want

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread H.S.
Ron Johnson wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/06/08 11:42, H.S. wrote: Hello, In a C++ program I am reading a data file for later processing and computations. While reading that data file, I want to keep track of data items (doubles) read. The data file is just a text

Re: C++ programming: keeping count of data items read from file

2008-05-06 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/06/08 11:42, H.S. wrote: > Hello, > > In a C++ program I am reading a data file for later processing and > computations. While reading that data file, I want to keep track of data > items (doubles) read. > > The data file is just a text file wi

Re: c programming reference on linux

2005-08-10 Thread Micha Feigin
On Wed, 10 Aug 2005 08:36:54 +0700 Ms Linuz <[EMAIL PROTECTED]> wrote: > Wackojacko wrote: > > >> Sorry, another lazy googling day ... > >> Anybody got links or hardcopy of some kind like C/C++ programming > >> reference on linux ? > >> Thanks a lot. > >> > >> --w.h-- > >> > > I found 'Teach Your

Re: c programming reference on linux

2005-08-09 Thread Ms Linuz
Wackojacko wrote: >> Sorry, another lazy googling day ... >> Anybody got links or hardcopy of some kind like C/C++ programming >> reference on linux ? >> Thanks a lot. >> >> --w.h-- >> > I found 'Teach Yourself C++ in 21 Days' quite useful having not > programmed in C, or any other language for th

Re: c programming reference on linux

2005-08-09 Thread Wackojacko
Sorry, another lazy googling day ... Anybody got links or hardcopy of some kind like C/C++ programming reference on linux ? Thanks a lot. --w.h-- I found 'Teach Yourself C++ in 21 Days' quite useful having not programmed in C, or any other language for that matter, before. Available at http:/

Re: c programming reference on linux

2005-08-09 Thread Christian Henz
> On 8/9/05, Ms Linuz <[EMAIL PROTECTED]> wrote: > > Sorry, another lazy googling day ... > > Anybody got links or hardcopy of some kind like C/C++ programming > > reference on linux ? > > Thanks a lot. > > The GNU C Library Manual: http://www.gnu.org/software/libc/manual/ cheers, Christian

Re: c programming reference on linux

2005-08-09 Thread David González
Bruce Eckel's Thinking in C++ Vol. 1 & 2. I love that book. On 8/9/05, Ms Linuz <[EMAIL PROTECTED]> wrote: > Sorry, another lazy googling day ... > Anybody got links or hardcopy of some kind like C/C++ programming > reference on linux ? > Thanks a lot. > > --w.h-- > > > -- > To UNSUBSCRIBE, ema

Re: C programming: Is there an exec (with no additional letters) call?

2003-06-19 Thread Thomas Krennwallner
Hi! On Wed Jun 18, 2003 at 02:49:26PM +0200, Sebastian Kapfer wrote: > On Tue, 17 Jun 2003 23:30:15 +0200, Thomas Krennwallner wrote: > > This code snippet will lookup the PATH environment and search for the > > "ps" executable. It will execute it and will pass "ps" as argv[0] and > > "x" as argv[

Re: C programming: Is there an exec (with no additional letters) call?

2003-06-18 Thread Sebastian Kapfer
On Tue, 17 Jun 2003 23:30:15 +0200, Thomas Krennwallner wrote: > This code snippet will lookup the PATH environment and search for the > "ps" executable. It will execute it and will pass "ps" as argv[0] and > "x" as argv[1]. It is equivalent to: > > $ ps x Don't you mean $ exec ps x -- Bes

Re: C programming: Is there an exec (with no additional letters)call?

2003-06-17 Thread Richard Heycock
As others have said 'exec' refers to the family of exec system calls. It is part of POSIX 1003. rgh On Wed, 2003-06-18 at 05:29, Shaul Karl wrote: > I was told that similar to execl, execlp et al there is also an exec > call. Yet when I run > > man exec > > I only get execl, execlp, exec

Re: C programming: Is there an exec (with no additional letters) call?

2003-06-17 Thread Pigeon
On Tue, Jun 17, 2003 at 10:29:25PM +0300, Shaul Karl wrote: > I was told that similar to execl, execlp et al there is also an exec > call. Yet when I run > > man exec > > I only get execl, execlp, execle, execv and execvp. No `pure' exec, one > without any additional letters. Can I safely

Re: C programming: Is there an exec (with no additional letters) call?

2003-06-17 Thread Nathan Poznick
Thus spake Shaul Karl: > I was told that similar to execl, execlp et al there is also an exec > call. Yet when I run > > man exec > > I only get execl, execlp, execle, execv and execvp. No `pure' exec, one > without any additional letters. Can I safely tell that person that he is > definit

Re: C programming: Is there an exec (with no additional letters) call?

2003-06-17 Thread Thomas Krennwallner
Hi! On Tue Jun 17, 2003 at 10:29:25PM +0300, Shaul Karl wrote: > I was told that similar to execl, execlp et al there is also an exec > call. Yet when I run > > man exec This is exec(3) which documents the exec family calls. AFAIK there is no POSIX exec() function. Please install the glib

Re: C programming under linux tutorial sites..

2001-12-27 Thread Arno
Petre Daniel <[EMAIL PROTECTED]> wrote: > > Where should i read about C programming under linux? > I need urls with download guides.. > http://www.advancedlinuxprogramming.com This book is published under the Open Publication License, you can get the full text in the download section. - Arno.

Re: C programming under linux tutorial sites..

2001-12-26 Thread Shaul Karl
> Where should i read about C programming under linux? > I need urls with download guides.. > > Petre L. Daniel,System Administrator > Canad Systems Pitesti Romania, > http://www.cyber.ro, email:[EMAIL PROTECTED] > Tel:+4048220044, +4048206200 > An ANSI C program is the same with any platform t

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Andrew Agno
Richard Cobbe writes: > heap. Unfortunately, this may or may not be the location of the root > error. While I'm a big fan of garbage collectors in general, I don't think You can always hope that it's a piece of memory you were dealing with before. Depending on the malloc debugger, you may als

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Richard Cobbe
Lo, on Thursday, July 26, Shaul Karl did write: > Program received signal SIGSEGV, Segmentation fault. > 0x400af19e in malloc () from /lib/libc.so.6 > (gdb) > > > How can it be? If malloc can not allocate memory it should return a NULL > pointer. How can it Seg fault? As Andrew Agno and Alan

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Shaul Karl
> > Try breaking the mallocs into separate lines to see which one fails: > > int errflag = 0; > if (!(node = (struct node *)malloc(sizeof(struct node { > errflag = 1; > } else { > if (!(node->data = (struct symbol *)malloc(sizeof(struct > symbol { >

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Alan Shutko
Shaul Karl <[EMAIL PROTECTED]> writes: > How can it be? If malloc can not allocate memory it should return a NULL > pointer. How can it Seg fault? You have most likely overwritten the end of an array and overwritten malloc's accounting info, causing a segfault next time you malloc something. --

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Shaul Karl
> > > On Thu, 26 Jul 2001, Shaul Karl wrote: > > > How can it be? If malloc can not allocate memory it should return a NULL > > pointer. How can it Seg fault? > > The internal state of the stack became corrupted. Try compiling with > "-lefence" (electric fence). Then reproduce the error. It wi

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Dimitri Maziuk
* Shaul Karl ([EMAIL PROTECTED]) spake thusly: ... > 193 enum flag insert_symbol(struct symbol *sym) > 194 { > 195 struct node *node; > 196 > 197 if (!((node = (struct node *)malloc(sizeof(struct node))) && > 198 (node->data = (struct symbol *)malloc(sizeof(s

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Rick Macdonald
Try breaking the mallocs into separate lines to see which one fails: int errflag = 0; if (!(node = (struct node *)malloc(sizeof(struct node { errflag = 1; } else { if (!(node->data = (struct symbol *)malloc(sizeof(struct symbol { errflag =

Re: C programming: Segmentation fault within malloc?

2001-07-26 Thread Shaul Karl
> Have you tried to look at the value sizeof(struct node)? It might be too big. > Otherwise, can you show us the backtrace in gdb. > gdb says sizeof(struct node) == 20. It is mostly a couple of pointers: struct node { enum colors color; struct node *left, *right, *parent;

Re: C programming: Segmentation fault within malloc?

2001-07-25 Thread Shao Zhang
Have you tried to look at the value sizeof(struct node)? It might be too big. Otherwise, can you show us the backtrace in gdb. On [Thu, 26 Jul 2001 03:15:46 +0300], Shaul Karl <[EMAIL PROTECTED]> wrote: > Breakpoint 2, insert_symbol (sym=0xbfffe25c) at symbols.c:197 > 197 if (!((node = (st

Re: C programming: What does this construct in printf(_(" means?

2001-06-20 Thread Brian May
[EMAIL PROTECTED] wrote: What does the construct _("What ever format string I use") means in the context of printf? For example: [00:50:20 tmp]$ grep -C1 printf\(_\( util-linux-2.11b/misc-utils/script.c if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {

Re: C programming: What does this construct in printf(_(" means?

2001-06-20 Thread Moritz Schulte
[EMAIL PROTECTED] writes: > What does the construct > >_("What ever format string I use") > > means in the context of printf? This construct is often used for 'gettext'. gettext translates text messages. >From gettext's info page: Many packages use `_' (a simple underline) as a keyword

Re: C programming

2000-08-08 Thread Shao Zhang
Hi, With your program, if you print out some values of x and y, you can see that y become very very small after a couple of iterations. When y is too small, the following statement become true: z = x+y, z == x because y is too small and is ignored due to th

Re: C programming

2000-08-05 Thread Eric G . Miller
On Sat, Aug 05, 2000 at 11:31:02AM -0500, Philip C Mendelsohn wrote: > On Fri, 4 Aug 2000, Eric G . Miller wrote: > > > I suggest going to comp.lang.c and checking the C FAQ. Specifically look > > for the inherent problem of putting the same variable on both sides of a > > relational operator: (x+

Re: C programming

2000-08-05 Thread Philip C Mendelsohn
On Fri, 4 Aug 2000, Eric G . Miller wrote: > I suggest going to comp.lang.c and checking the C FAQ. Specifically look > for the inherent problem of putting the same variable on both sides of a > relational operator: (x+y) > x In this case, a little algebra shows that all you need to check is y >

Re: C programming

2000-08-04 Thread Eric G . Miller
To follow up: how floating point numbers are represented in the machine during computations may vary slightly from how they get represented when stored into a variable. That is, the evaluation of (x+y) may have greater numerical precision then the result of z = x + y. In the second case, there "a

Re: C programming

2000-08-04 Thread Eric G . Miller
I suggest going to comp.lang.c and checking the C FAQ. Specifically look for the inherent problem of putting the same variable on both sides of a relational operator: (x+y) > x If memory serves, the behavior is "undefined" -- so don't do it! On Fri, Aug 04, 2000 at 11:55:36PM +0200, Christophe TR

Re: C programming

2000-08-04 Thread Christophe TROESTLER
On Fri, 4 Aug 2000, John Reinke <[EMAIL PROTECTED]> wrote: > > 1) This is NOT for a programming assignment. ;-) Ho, no! :-) These are just some experiments. > 2) Using the comma within a condition is treated as AND (&&). That's > messier code than I usually create. Well, this is uncorrect. E

RE: C programming

2000-08-04 Thread Sean 'Shaleh' Perry
On 04-Aug-2000 Christophe TROESTLER wrote: > Hi the list, > > I apologize if that is a little bit off topic but I am a bit puzzled > and I know there are experts on this list. I would like an > explanation on why the two "for" below give different results. > my comment here is -- use

Re: C programming

2000-08-04 Thread John Reinke
Quick answer here - I'll make two assumptions: 1) This is NOT for a programming assignment. ;-) 2) Using the comma within a condition is treated as AND (&&). That's messier code than I usually create. Making the z = x + y assignment is part of the loop's condition, so it is evaluated at whatever

Re: c programming question w/ ncurses

1998-08-12 Thread Jens B. Jorgensen
Fix below: Keith wrote: > I am trying to fumble through learning how to do some C programming. > In the book I am using, Beginning Linux Programming they are now trying > to use ncurses. I am getting the following errors when I try to compile > my source. I am compiling with this command: > > $ c