HDTenEightyP/NetNews huggingface dataset:
From: rich@kastle.com (Richard Krehbiel)
Subject: Re: strtol() return values
Organization: Kastle Development Associates, Arlington, VA, USA
Date: Thu, 28 Jan 1993 09:47:46 GMT

In article <1993Jan26.123614.10840@sco.com> md@sco.COM (Michael Davidson) writes:

>   ric@updike..sri.com (Richard Steinberger) writes:
>
>   >	strtol() returns a long int when successful.  If a non-numeric
>   >string is encountered, 0 is returned.  Unfortunately, errno doesn't seem
>   >to be set.  Here's the question:  If a string like, "0" or "000"
>   >is encountered, I also get a 0 returned from strtol(). Is there an easy,
>   >elegant way to check for this without examing each char?  
>
>   Yes - try something like this:
>
>       char	**p;
>
>       if ((value = strtol(str, p, 0)) == 0 && *p == str)
>           printf("strtol() failed!!\n");
>

    char	*p;
    if ((value = strtol(str, &p, 0)) == 0 && p == str)
        printf("strtol() failed!!\n");

    Note the change from char **p to *p.  The previous fragment left
out (possibly as an exercise to the reader) the technicality of "where
does p point?"

    Since failure is easily detected by the pointer compare, you can
leave out the compare value==0:

    value = strtol(str, &p, 0);
    if (p == str)
        printf("strtol() failed!!\n");

    Unrelated question:

    I had to write a strtoul function because my environment didn't
provide one.  I couldn't find anything which says what strtoul should
do if the base parameter is not 0 or 2 through 36.  What should it do?
Is this implementation-defined?  (Mine just uses base ten.)
--
Richard Krehbiel              rich@kastle.com or richk@grebyn.com
OS/2 2.0 will do for me until AmigaDOS for the 386 comes along...
Newsgroups: comp.lang.c
From: mccauley@ecn.purdue.edu (Darrell McCauley)
Subject: Re: qsort/pointer question (should be in FAQ?)
Followup-To: comp.lang.c
Organization: Ag Engineering Dept, Purdue University 
Date: Thu, 21 Jan 1993 10:26:41 GMT

In article <C16Boy.Lo5@portal.hq.videocart.com>, dfuller@portal.hq.videocart.com (Dave Fuller) writes:
|> mccauley@ecn.purdue.edu (Darrell McCauley) writes:
|> : sorry for what is probably a simple question, but qsort always
|> : gives me trouble. I need to sort a 2 dimensional double array:
|> : 
|> :   qsort (z, 10, 2*sizeof (double), zcmp);
|> : 
|> : and I cannot figure out how to write the comparison function.
|> : My attempt at sorting by the first column is below. Can you
|> : fix it?  What if I wanted to sort by the second column?

|> say we have a 2-d char array (each char being 1-byte for example sake)
|> 
|> char x[2][5];
|> 
|> what it looks like in memory is: 11111  (1st row, followed by . . )
|>                                  22222  (2nd row)
|> these will be contiguous. (1111122222) in memory.

Is this the case when the array is dynamically allocated? According to the
FAQ, you have to allocate nrows*ncolumns in one malloc call to get
contiguous memory chunks (even then, though, are you assured of getting
contiguous memory? If nrows*ncolumns is too large of a chunk, won't
unix split it up among different memory locations?). Anyway, sticking the
the problem at hand, I'm doing memory allocation the normal way:

         double **array;
	 array = (double **)malloc(nrows * sizeof(double *));
         for(i = 0; i < nrows; ++i)
           array[i] = (double *)calloc(ncolumns * sizeof(double));

If memory is allocated a another way (or if pointers are
rearranged), couldn't qsort be usable?  qsort is attractive, 
not because of performance, but availability.

|> By telling qsort (2 * sizeof(char)) for the element size it will step 
|> through the data as follows
|> 
|> 1111122222
|> ^ ^ ^ ^ ^
|> 
|> definitely NOT what you want.

|> If you want to do a 2-d array sort (by row i assume), you are going to
|> be writing your own routines to do it. 

This doesn't sound too enjoyable. If qsort just absolutely cannot be used,
does anyone have sources for other sorts that are completely freely 
distributable?

|> Dave Fuller
|> dfuller@portal.hq.videocart.com
-- 
James Darrell McCauley                Dept of Ag Engineering, Purdue Univ
internet: mccauley@ecn.purdue.edu     West Lafayette, Indiana 47907-1146, USA
bitnet: mccauley%ecn@purccvm          UUCP: pur-ee!mccauley
Newsgroups: comp.lang.c
From: damatt01@starbase.spd.louisville.edu (David A. Mattingly)
Subject: Roman Numerals
Date: Tue, 26 Jan 1993 17:18:42 GMT
Organization: University of Louisville


Does anyone know of an integer-to-Roman-numeral converter? I know I saw one in
a collection of utilities, maybe on simtel20...


-- 
        Dave Mattingly                   I am the master of my fate; 
damatt01@ulkyvx.ct.louisville.edu        I am the captain of my soul.
        (502) 584-6707                        --- Invictus
From: smclewin@ultrix.ramapo.edu (Scott M McLewin)
Newsgroups: comp.lang.c
Subject: WANTED: info on automated testing tools
Date: 25 Jan 1993 23:30:47 -0600
Organization: UTexas Mail-to-News Gateway
NNTP-Posting-Host: cs.utexas.edu

 
 
 
 
I am looking for infomation on automated software testing tools and would like 
advice on what tools are available and their relative merits.  I am running on 
an MS-DOS platform.
         
I am looking for a program which will excercise the user interface, capture 
and compare screen output, etc.  Presently, we are looking for something 
similar to Ghost from Vermont Creative Software.
 
Please mail any replies, as I cannot keep up with the news as often
as I would like to.   :(
 
 
Scott M McLewin
smclewin@ultrix.ramapo.edu
Newsgroups: comp.lang.c,comp.lang.fortran,sci.engr.mech
From: jjd@cray.com (Jeff Drummond)
Subject: Re: SI Units Quiz
Organization: Cray Research, Inc.
Date: 21 Jan 93 09:57:36 CST

In article <1993Jan21.004320.16522@draco.macsch.com> dnl@convex.is.macsch.com (David Lombard) writes:
>Here's a quick SI units quiz.  What is the multiplier for each of
>the following prefixes.  For extra credit, what is the symbol
>(be careful, case is significant).
>
>	atto
>	centi
>	deca
>	deci
>	exa
>	femto
>	giga
>	hecto
>	kilo
>	mega
>	micro
>	milli
>	nano
>	peta
>	pico
>	tera
>	yocto
>	yotta
>	zepto
>	zetta
>
>Have fun!
>DNL

Too easy.  Here's the prefix table from our units(1) command:

        1e-24,  "yocto",
        1e-21,  "zepto",
        1e-18,  "atto",
        1e-15,  "femto",
        1e-12,  "pico",
        1e-9,   "nano",
        1e-6,   "micro",
        1e-3,   "milli",
        1e-2,   "centi",
        1e-1,   "deci",
        1e1,    "deka",
        1e2,    "hecta",
        1e2,    "hecto",
        1e3,    "kilo",
        1e6,    "mega",
        1e6,    "meg",
        1e9,    "giga",
        1e12,   "tera",
        1e15,   "peta",
        1e18,   "exa",
        1e21,   "zetta",
        1e24,   "yotta",

The first two and last two were recent additions, as you probably know
(see "Science News", 1/16/93).

>                        MY_COMMENTS, MY_OPINIONS.
>
>David N. Lombard    The first thing we do,         The MacNeal-Schwendler Corp
>dnl@macsch.com      Let's kill all the lawyers.    815 Colorado Blvd
>(213) 259-4911      II Henry VI, IV.ii             Los Angeles, CA  90041

-Jeff    jjd@cray.com
--
"10 yottaflops is a lotta flops."   -me
Xref: sparky comp.lang.c:20102 comp.lang.c++:19797
From: Jon Freivald <jaf@jaflrn.UUCP>
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: need simple DOS text editor function (Borland Turbo C++ preferre
Date: Fri, 22 Jan 93 13:44:10 EST
Organization: The Wizzard's Cave, East Meadow, NY

duniway@hardy.u.washington.edu (Robert Duniway) writes:

> I posted this request before, but as numerous people pointed out I was not
> specific enough.  I am writing a program to run psychology experiment.  This
> requires that subject enter a brief message into a text window.  I would like
> them to be able to correct typo's, etc. in a fairly easy manner (say by using
> arrow keys to navigate and intersing or typing over text on screen). I would
> also like to enable a word wrapping feature.  This is obviously not a trivial
> task, and since it is not central to what I am trying to develop (an experime
> I was hoping that someone who had done something similar would be willing to 
> show me how they did it.  If you can help please email me and I will be
> appropriately grateful.
> 
> As to the specifics I left out last time.  I am running MS-DOS (5.0) and 
> using Borland's Turbo C++ 3.0 compiler.  If you have something on a different
> compiler that is not heavily dependant on library functions I would be 
> interested in looking at it.  If it matters I'm running on a 286 with VGA 
> graphics.
> 
> Bob Duniway

I mailed you source code once already and have done so again today -- if
you don't get it, please reply direct to me so we can work out a good
address for you...

Jon

=============================================================================
                   Jon Freivald ( jaf%jaflrn@uunet.UU.NET )
	 Nothing is impossible for the man who doesn't have to do it.
		    PGP V2 public key available on request
=============================================================================
Newsgroups: comp.lang.c
From: dwj@iedv6.acd.com ( Dan Johnson         )
Subject: Re: Where does system("cd ./sudir") go ?
Organization: Applied Computing Devices, Inc., Terre Haute IN
Date: Thu, 28 Jan 1993 22:38:30 GMT

In article <C1JMDn.9Gw@acsu.buffalo.edu> zshi@acsu.buffalo.edu (Zhixin Shi) writes:
>I use
>            system("cd ./sudir")
>it looks like going into the subdir then come back when the program
>finished.

I assume this is under UNIX.

The system() function forks a child process and the command executes
in that process.  To change the current directory within a process,
you need to use the chdir() system call (probably in section 2 of your
manual).
-- 
Daniel W. Johnson                  Applied Computing Devices, Inc.
Home: 71520.367@CompuServe.COM     Work: dwj@iedv1.acd.com
      DanielJ13@aol.com                  39 25 02 N / 87 19 55 W
                - this space unintentionally left blank -
From: mcknight@etcetc.fidonet.org (Chuck McKnight)
Sender: uucp@etcetc.fidonet.org
Newsgroups: comp.lang.c
Subject: Re: Need info for Turbo-C on storing lots of data within sourc
Date: Sat, 23 Jan 1993 08:41:01 -0600

 NS>From: noah@ucscb.UCSC.EDU (Noah Spurrier)
 NS>Organization: University of California; Santa Cruz


 NS>Keywords: Turbo C data

 NS>I have a program that stores a compressed picture of its title
 NS>screen. The
 NS>title screen is a graphic image. Also the program stores some
 NS>documentation.
 NS>The program is fairly short. I do not want to store this data in
 NS>separate files. What I did is use HUGE arrays with initialization
 NS>to the
 NS>big chunk of data. This works fine, but I notice that some people
 NS>have had
 NS>the program crash with something like the following error:

 NS>STACK OVERFLOW

 >or 

 NS>STACK FULL, SYSTEM HALTED

 NS>Another person told me that these huge arrays were being stored in
 >the
 NS>stack segment and that because they just sit on the stack and never
 NS>move
 NS>this does not give my program much room to work with.

 NS>Would simply making the array STATIC help things?

 NS>I also farmalloc a 64K buffer, but I don't think that should hurt
 NS>the stack
 NS>at all. 

 NS>How can I get Turbo-C to store these variables in the data segment
 NS>instead of
 NS>the stack?

 NS>Here is an example of how I declare and initialize one of my
 NS>arrays:
 NS>unsigned char far TITLE_DATA [(X_TITLE*Y_TITLE/4)] =
 NS>{ 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
 NS>85, 85, 85, 85,
 NS>  85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
 NS>85, 85, 85, 85,
 NS>  85, 85, 85, 85, 85, 85,117, 85, 85, 85,117, 85, 85, 85,117, 85,
 NS>85,213, 85, 85,
 NS>  85, 85, 85, 85, 85, 87,213, 85, 85, 87,213, 85, 85, 87,213, 85,
 NS>95, 85, 85, 85,
 NS>  85, 85, 85, 85, 85,127,213, 85, 85,127, 85, 85, 85,127, 85,
 NS>85,255, 85, 85, 85,
 NS>  85, 85, 85, 85, 85,255,213, 85, 85,253, 85, 85, 85,253, 85,
 NS>87,255, 85, 85, 85,
 
 NS>....
 NS>....};

 NS>Thanks for even bothering to read this damn thing!

What memory model are you using?  If you're doing this in the small memory
model, realize that your code and data segments are the same thing.  Try going
to the large memory model (biggest benefit is that you don't have to use the
far modifier as your pointers are automatically far pointers).  Just some
ideas.

Chuck McKnight
From: TEDUPUIS@HANNA2.NLU.EDU
Newsgroups: comp.lang.c
Subject: advanced c
Date: 23 Jan 1993 07:53:28 -0600
Organization: UTexas Mail-to-News Gateway
NNTP-Posting-Host: cs.utexas.edu

any recommendations on books on advanced c data structures?

Ron Dupuis
email: tedupuis@hanna2.nlu.edu
From: proctori@p4.cs.man.ac.uk (Dave Proctor)
Newsgroups: comp.lang.c
Subject: Please help! Integer longer than 32 bits required.
Summary: please god
Keywords: help help help!
Date: 26 Jan 93 16:13:13 GMT

I dunno how common this question is, but it doesn't appear in the FAQ's
so I thought no-one might have asked it, here goes.

Im doing a realtime 3d graphics program. To assist in the 'realtime-ness' of it
I have implemented integer arithmetic throughout. This results in bit shifting to
imply a decimal place in every multiplication. The problem with this is that I
lose 14 bits of integer every time. Its not an accumulation problem, just I need
a bigger quantity than 32 bits. 64 bits would be wonderful, but C doesn't seem
to want me to have em....

Any answers would be gratefully received.

 - Dave.

-- 
    /\    /\     __   __  /_ 
   /  \  /  \   /  / / / /  / /
__/    \/    \_/__/_/ /_/__/_/____________________________________________
____________________________/                           howeg@uk.ac.man.cs
Newsgroups: comp.lang.c
From: aws@iti.org (Allen W. Sherzer)
Subject: Function prototype problem
Organization: Evil Geniuses for a Better Tomorrow
Distribution: na
Date: Sun, 24 Jan 1993 01:10:56 GMT


An image processing library I am using has some function prototypes which looks
like this:

count gc foo(int a, ...)


My compiler (microsoft C 5.1) doesn't like this very much. Anybody know
what 'count' and 'gc' are for? Please answer via email.

   Allen
-- 
+---------------------------------------------------------------------------+
| Allen W. Sherzer | "A great man is one who does nothing but leaves        |
|  aws@iti.org     |  nothing undone"                                       |
+----------------------143 DAYS TO FIRST FLIGHT OF DCX----------------------+
From: wjs@re3sc139h.gmr.com
Newsgroups: comp.lang.c
Subject: REQ: Public Domain CALLTREE program
Date: 27 Jan 93 19:26:14 GMT
Organization: Electronic Data Systems Corp.

Does anyone know of a good public domain call-tree program for C
language syntax (available on the Internet) ?  I would prefer it
if source code is included.  

Please respond directly by email.

		 Thanks,

		 Walt Stuart   wjs@re3sc139h.gmr.com
Newsgroups: comp.lang.c
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Subject: Re: Where does system("cd ./sudir") go ?
Organization: University of Helsinki
Date: Thu, 28 Jan 1993 17:28:09 GMT

zshi@acsu.buffalo.edu (Zhixin Shi) writes:
>    I tried to make a program using system call to change dir, but when
>I use
>            system("cd ./sudir")
>it looks like going into the subdir then come back when the program
>finished.

The details of how system() works depend on the implementation and the
environment where the program is run.  On most systems, system()
starts a new program (command interpreter or shell) to execute the
command given to it.  On some system, when the shell (or whatever)
changes _its_ work directory, it doesn't affect any other program.
This is the case with Unix, for example (your example would indicate
Unix, or something very similar).  On other systems (MS-DOS, for
example) it _does_ affect, and changes the work directory for all
programs.

>    Is there any idea how to make the program stay into the subdir or 
>simply using some other calls to do this?

There is no portable way.  Under Unix and MS-DOS, look for the chdir()
function.

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
From: chorn@eastwind.mcds.com (Christopher Horn)
Newsgroups: comp.lang.c
Subject: How do you read binary data piped into stdin?
Summary: How to make stdin read past EOF marker (ascii 26)
Keywords: stdin, redirection, binary data
Date: Thu, 21 Jan 93 23:35:22 EST
Reply-To: chorn@eastwind.mcds.com
Organization: The East Wind  +1 201 875 7063


I'm relatively new to C, so still have a lot to learn, so I apologize
if this is a silly question. I need to read raw binary data from
stdin (it is being piped in) but it appears stdin operates in text
mode. The first ascii 26 that comes along triggers end of file, and
I can't read the rest of the data. Could someone please explain, or
better yet show me a short peice of code, that could do this? The
answer is probably obvious, but it eludes me at the moment. Thanks
a lot!


 ---
 Christopher Horn           |  "We're all caught in a state of decay..."
 chorn@eastwind.mcds.com    |  The East Wind  +1 201 875 7063
Newsgroups: comp.lang.c,comp.lang.fortran
From: silvert@biome.bio.ns.ca (Bill Silvert)
Subject: Re: calling a Fortran subroutine from a C program
Reply-To: silvert@biome.bio.dfo.ca (Bill Silvert)
Organization: Habitat Ecology Div., Bedford Inst. Oceanography
Distribution: na
Date: Sat, 23 Jan 1993 15:21:53 GMT

In <1993Jan22.233618.17814@chpc.utexas.edu> michael@chpc.utexas.edu (Michael Lemke) writes:

>Not quite.  To make it really clear:  The difference is
>	CHARACTER*100 STRING
>or
>	CHARACTER*1 STRING(100)
>which are very different data structures.   The latter is an array, the
>first is a single variable.  I don't care how C chews its memory, it can
>hardly distinguish these two cases.  The last is pretty close in
>functionality to C's concept (except for having a length stored
>somewhere) as you'd need something like strcpy to copy data.

It seems to me that there would be absolutely no difference in memory
allocation between these two cases, and that they would appear identically
to a C program.  Thus in terms of passing them to a C program I can't
see what the difference would be.  The only difference is how the Fortran
code refers to them.

So far as C is concerned, the value of string_(n-1) can be interpreted
equally well as the nth byte in the string string_, or as the nth
member of an array of one-byte strings.

Caveat: I have been told in the past that there is no requirement for
Fortran to allocate contiguous memory for arrays, but since I have never
run into a case where this was not done I don't worry about it.
-- 
------------------------------------------------------------------------
William Silvert, Habitat Ecology Division, Bedford Inst. of Oceanography
P. O. Box 1006, Dartmouth, Nova Scotia, CANADA B2Y 4A2.  Tel. (902)426-1577
InterNet Address: silvert@biome.bio.dfo.ca
Newsgroups: comp.lang.c
From: brown@NCoast.ORG (Stan Brown)
Subject: Re: Microsoft library access from Turbo C?
Organization: Oak Road Systems, Cleveland Ohio USA
Date: Sat, 23 Jan 1993 10:25:35 GMT

In article <1993Jan21.171455.215@kenyon.edu> sullivan@kenyon.edu writes:
>I have some DOS hardware with a software library to use it written for
>Microsoft C (ver 4.00). Is there a way to link code I write in Turbo C++ (ver
>2.00, I think) to this library?

See question 203 in the FAQ for comp.os.msdos.programmer.
-- 
Stan Brown, Oak Road Systems                    brown@Ncoast.ORG
Cleveland, Ohio, USA
"Compared to my life, the last man on a chain gang is thoroughly
enjoying himself."                   __Holiday__ by Philip Barry
From: KSADEGH@auvm.american.edu
Newsgroups: comp.lang.c
Subject: Ok,Ok (was:matrix overlapping!!!)
Date: 21 Jan 93 16:57:19 GMT
Organization: The American University - University Computing Center

Ok, Ok, I admit it. I was converting a pascal program to C. And in doing so,
I was changing the codes in the .pas file directly. This is why I took the
pascal matrix definition as default. I know, that was stupid. It wont
happen again.

Thanks for all your replys
k1
---
------------------------------------------------------------------------
PUSH, if that doesn't work
PULL, if that doesn't work
we're probably CLOSED
------------------------------------------------------------------------
Kayvon Sadeghi                    k.sadeghi@ieee.org
Voice:202/244-0789
Newsgroups: comp.lang.c
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Subject: Re: should main be prototyped?
Organization: University of Helsinki
Date: Mon, 25 Jan 1993 10:19:06 GMT

staff@rabbit.augs.se (Staffan Friberg) writes:
>Sorry to burst in like this but isn't this wrong? I was told that you should
>use *argv[] instead of **argv. They are clearly not the same thing.

Actually, they are the same thing.

>If this is a FAQ I'm sorry but I have only been here a few days.

Not an excuse, IMHO.  There is a FAQ, and this is covered by it, and
reading the relevant FAQ or FAQs before posting is considered common
courtesy.

>BTW. is there a FAQ-sheet somewhere and if that is the case, where can I find
>it?

The group news.answers contains (nearly) all FAQs.  If they have
expired on your site, try ftp to rtfm.mit.edu, or the mailserver on
that site (mail-server@rtfm.mit.edu).  (This should be common Usenet
knowledge.)

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
Newsgroups: comp.lang.c,comp.lang.c++
From: pete@borland.com (Pete Becker)
Subject: Re: C/C++ Correctness (was: Re: C/C++ Speed)
Originator: pete@genghis.borland.com
Organization: Borland International
Date: Wed, 27 Jan 1993 23:40:10 GMT

In article <1k6m67INNgqv@emx.cc.utexas.edu> jamshid@emx.cc.utexas.edu (Jamshid Afshar) writes:
>
>	int i;
>	int** p = &i;
>
>But isn't the above code legal C?  Isn't an ANSI C compiler *required*
>to compile the code (and required to issue some kind of warning).  My
>point is that the above code will be compiled by an ANSI C compiler,
>but not by a C++ compiler.
>

	Yes, it is legal C.  I was thinking C++ when I wrote my earlier 
response.
	No, the compiler is not required to issue a warning.  There are no
mandatory warnings in ANSI C.  The only requirement on diagnostics is that
the compiler must generate a diagnostic when it attempts to compile a 
non-conforming program.
	-- Pete


Newsgroups: comp.lang.c,comp.lang.c++