HDTenEightyP/NetNews huggingface dataset:
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: strcpy implementation question
Date: 27 Aug 92 13:17:12 EDT

pinkas@caraway.intel.com (Israel Pinkas) writes:
>That's the problem.  I claim that copying past the end of the string is
>wrong, as the user may be building a string up backwards.  The compiler
>writers claim that there is nothing in the ANSI spec that claims that the
>memory past the destination's terminator is inviolate.

I didn't see anything in the ANSI spec for strcpy() that seemed to explicitly
claim that strcpy() doesn't zero all variables named "ferdinand" in a program,
but I seriously doubt that a run-time library which did that would be
compliant.  strcpy() copies a string, and does nothing else -- it doesn't
put random data after the string, it doesn't zero after the string, it
doesn't zero all variables named "ferdinand".

Newsgroups: comp.lang.c
From: pegasus@csd4.csd.uwm.edu (David R Hucke)
Subject: Re: Giles' Manual Mania (Was - Re: About the 'F' in RTFM)
Followup-To: alt.sex
Organization: Computing Services Division, University of Wisconsin - Milwaukee
Date: Thu, 27 Aug 1992 14:07:25 GMT


Would you two please grow up?  Just realize that an opinion is an opinion and
if you prefer one system over another, then more to you.  Just stop
acting like whining babies.
-- 
pegasus@csd4.csd.uwm.edu                David R. Hucke
                                        UW-Milwaukee Film Major
--
From: zrwb14@hou.amoco.com (Randy Byrne)
Newsgroups: comp.lang.c
Subject: vax floating point bit structure
Date: 28 Aug 92 12:16:13 GMT
Reply-To: zrwb14@hou.amoco.com
Organization: Amoco

Since this is just about the largest "comp" user group I thought I'd try posting this question here:  Does anyone know what the bit structure of a VAX floating point number is?  The only information I have so far is that each word of the byte sequence is reversed i.e. 1032, not 0123.  I need to know which bit is the sign bit, are the exponent and/or the mantissa normalized (i.e. is some number added to the exponent or mantissa), is the exponent base 2,8, or 16, is the two's compliament of the exponen









antissa used instead of the "plain" binary number, etc., etc.  If you can help please respond by private E-mail or post back to "comp.lang.c" (I have to write a translation in C).  Thanks in advance.	

Randy
Newsgroups: comp.lang.c
From: fjh@mundil.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: printf() waiting for loop(s) to finish - how to override...
Keywords: printf(), waiting for loop finish, gcc and cc _but_ not ztc, bcc.
Organization: Computer Science, University of Melbourne, Australia
Date: Wed, 2 Sep 1992 08:17:30 GMT

jracine@weber.ucsd.edu (Jeff Racine) writes:

>When I compile a program with the following code on an HP system using
>cc or using gcc (both on the HP or under MessDOS) the following
>printf() statement only prints after both loops are finished. Since
>the statement tells me where in the total number of replications the
>program currently is, this depeats the purpose of the statement!
>
>Question: Is there a (simple) way to override this delayed screen I/O?

Yes, call fflush(stdout) after each call to printf.

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Newsgroups: comp.lang.c
From: kpearce@magnus.acs.ohio-state.edu (BULLDAWG)
Subject: sscanf?  What am I doing wrong?
Organization: The Ohio State University
Date: Mon, 31 Aug 1992 15:46:55 GMT

Hi:

	Forgive me if this is a stupid question:

I am using Borland C++ and am compiling as default C file.

Why doesn't this work?

char command[80]  \* This is data from a file read off of the disk 'r' type.*\
char partA[20];   \* and is for example "transmit data" *\
char partB[60];
char tran[] = "transmit"
sscanf(command,"%s %s",partA, partB);

void main(void)
{
  if (partA==tran)
  {
  	printf("We have a match\n");
  }
  else
  {
  	printf("failed again  :(  \n");
  }
}

This always fails.  I have tried putting \r\0 and various other control
characters at the end of the ttest string tran[] to no avail.

Putting a printf("%s\n %s\n %s\n",command,partA,partB) yields the correct output
e.g.
    transmit data
    transmit
    data

So what am I doing wrong?  As far as the program goes they don't match.  But I
say they do.

Please e-mail to me.  Thanks.

Ken Pearce
Newsgroups: comp.lang.c
From: cee1@Ra.MsState.Edu (Charles Evans)
Subject: Reading from text file
Organization: Mississippi State University
Date: Wed, 26 Aug 1992 19:45:01 GMT

Ok, needing to read x number of lines of a data file with 2 integers
on each line (not knowing the # of lines).. so my deal is to figure
out an EOF checker.. here is what i am trying to do.. any pointers of
this matter will be most appreciative very quickly....

.....
FILE *fp
int Index = 0;
int Looper;
char year[100];      /* would rather use a pointer, not knowing how big itis
char value[100];     /* same */

fp = fopen("foo.dat","r"); 

while (fp != EOF)
{
	fgets(fp,"%d",year[Index]);
     	fgets(fp,"%d",value[Index]);
	Index++;
}
for (Looper = 0; Looper = Index; Looper++)
{
	printf("Values: %d and d\n",year[Looper],value[Looper]);
}.

.,...

thanks

chuck

--
+--------------------+-----------------------+------------------------+
|  Charles E. Evans  |  cee1@ra.msstate.edu  |  All things are green  |
|    iDLE CHATTEr    |  cee1@MSSTATE.BITNET  |  unless they are not.  |
+--------------------+-----------------------+------------------------+
From: tv@risken.vd.volvo.se (Taisto Varis)
Newsgroups: comp.lang.c
Subject: C preprocessor include
Date: 4 Sep 92 14:15:40 GMT

Is it possible to change the behaviour of the #include "..." 
in the preprocessing phase of the C compiler.

It does not look for UNIX environmenmt variables.
Is there a way to keep a file from getting included more than once.
Note, that i do not want the file to be opened at all.

thanks for any help
From: jracine@weber.ucsd.edu (Jeff Racine)
Newsgroups: comp.lang.c
Subject: printf() waiting for loop(s) to finish - how to override...
Date: 2 Sep 1992 04:44:25 GMT
Organization: University of California, San Diego
Distribution: world
NNTP-Posting-Host: weber.ucsd.edu
Summary: Some compilers do, some don't...
Keywords: printf(), waiting for loop finish, gcc and cc _but_ not ztc, bcc.

When I compile a program with the following code on an HP system using
cc or using gcc (both on the HP or under MessDOS) the following
printf() statement only prints after both loops are finished. Since
the statement tells me where in the total number of replications the
program currently is, this depeats the purpose of the statement!

This does not happen when the program is compiled with bcc or ztc
(Borland or Zortech). 

Question: Is there a (simple) way to override this delayed screen I/O?

Here is the offending code (if it is of any use). Thanks in advance
for any help or pointers.

------------------------------------------------------------------
        for(i = 0; i < num_cv_rep; i++) {

          printf("\rReplication %d", i+1); /* non-executing statement */

          fprintf(File11,"%f\t", mker_ne(x, scale_fac, num_va, num_ob));

          for(m=0; m < num_va; m++) {
            fprintf(File11,"%f\t", scale_fac[m]);
            scale_fac[m] += inc_flt;
          }

          fprintf(File11, "\n");

        }
-----------------------------------------------------------------
p.s. the function mker_ne() is a computationally intensive function
and may take, say, 20 seconds to execute - I wish to execute the
function with different values of scale_fac, say, 100 different
values. Thus the value in knowing where the program is at.
-- 
-----------------------------------------------------------------------------
Jeff Racine        
jracine@weber.ucsd.edu
racine@nexus.yorku.ca
Newsgroups: comp.lang.c
From: joet@dcatlas.dot.gov (Joe Trott)
Subject: Re: New Comer - Please Help !
Organization: U.S Dept. of Transportation
Date: Fri, 28 Aug 1992 15:22:43 GMT


If textbooks for single courses are hitting the $50-$75 level *for a _single_
course*, then I cannot see that asking students to drop a few hundred on
a manual set they will use over and over again (possibly beyond graduation)
is the least bit unreasonable.  I strongly suspect that the more motivated
students do so.  I recognize that some may be trying to save money, but see
sentence #1.

-JTT

Newsgroups: comp.lang.c
From: tmike@cmptrc.lonestar.org (T. Mike Howeth)
Subject: Re: strcpy implementation question
Date: Fri, 28 Aug 1992 01:14:54 GMT
Organization: CompuTrac Inc., Richardson TX

In article <14173@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
|In article <PINKAS.92Aug24183511@caraway.intel.com>, pinkas@caraway.intel.com (Israel Pinkas) writes:
|> The basic question
|> is whether it is valid for strcpy to modify the destination past the end of
|> the string that it copies in.  [abstract code deleted]
|
|There is a very basic problem which explains why strcpy() should touch
|only strlen(source)+1 chars:
|	characters following the intended end of the source MAY NOT EXIST
|	characters following the intended end of the destination MAY NOT EXIST
|	characters following the intended end of the source may exist
|	AND YET NOT BE INITIALISED.

And don't forget the BEST reason: such an access will often abort your program
due to a protection fault.  (not ALWAYS, of course, but often enough!)


-- 
tmike@cmptrc.lonestar.org                                               __
"Whoever said 'getting there is half the fun'                           \/
    has never ridden in a class 8 probe!"
Newsgroups: comp.lang.c
From: RICHARD@CLYDE.ttt.kth.se
Subject: Re: Why should POINTERS be so damn hard to understand ?
Organization: Department of TeleTransmission Theory
	<1992Aug27.135946.6622@infonode.ingr.com>
	<17islrINNh6c@early-bird.think.com>
Date: Thu, 27 Aug 1992 18:33:19 GMT

In article <17islrINNh6c@early-bird.think.com> barmar@think.com (Barry Margolin) writes:

This was an example of a tight loop with "untyped pointers":

   int a[1000];
   char *_i;

   for (_i=(char *)a; _i<a+1000*sizeof(int); _i+=sizeof(int))
       *(int *)_i = whatever();

   I would epect this to produce almost identical code.  And in a language
   where pointers weren't typed, you wouldn't need all the casting.

Of course, and in C, as you HAVE typed pointers, you wouldn't need either
type casts OR sizeof!

--
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! Richard Levitte, System manager       ! tel: int+46-8-790 64 23           !
! Royal Institute of Technology         ! fax: int+46-8-791 76 54           !
! Department of Teletransmition Theory  ! Internet: richard@ttt.kth.se      !
! S-100 44 Stockholm, Sweden            !                                   !
!---------------------------------------------------------------------------!
Newsgroups: comp.lang.c
From: vinod@yaya.WPI.EDU (Vinod K Nair)
Subject: HPUX /usr/include/*.h
Organization: Worcester Polytechnic Institute
Date: Wed, 2 Sep 1992 14:16:21 GMT

Hi all,
	I was recently installing a C++ compiler on my HP9000/845 machine
running HP-UX 7.0, when I accidentally kept the /include directory to
be /usr/include. Result : Disaster (well I'm a novice sys-admin)
	I was wondering if any-one would be kind enuf to 
either direct me to a source where I can ftp these header files.. or
could some-one with a HP machine be kind enuf to let me have a copy of
these files.. Please!!!! I have back-up tapes but a broken tape-drive..
	Thanks in advance.
Vinod
-- 
Vinod
email : vinod@wpi.wpi.edu
From: chans@marsh.cs.curtin.edu.au (Sean Chan)
Newsgroups: comp.lang.c
Subject: Re: Copying file of int to 2-d array
Date: 30 Aug 92 16:38:41 GMT
Organization: Curtin University of Technology

>|   /* allocate space for array */
>|   array = (int **) malloc (98 * sizeof (int *));
>|   for (counter = 0; counter < 98; ++counter);
>|       array = (int *) malloc (98 * sizeof (int *));
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>       array[counter] = (int *) malloc (98 * sizeof (int *));

Sorry people, I did have the array[counter] in my program (it was a typo
error when I retyped my program for the post). Anyway, the problem is
solved thanks to everyone.

However, I have an alternative query, after using the dynamic array, is
it possible for me to free it with one command :-

   free (array)

or do I have to set a loop to free the array??

   for (counter = 0; counter < 98; ++counter)
       free (array[counter];
   free (array);

Any help will be appreciated...Ta!!

Sean
Newsgroups: comp.lang.c
From: adam@microware.com (Adam Goldberg)
Subject: Re: why execve() call wouldn't return to the calling program?
Keywords: execve, unix, process
Organization: Microware Systems Corp., Des Moines, Iowa
Date: Wed, 2 Sep 1992 21:19:56 GMT

In article <15277@ksr.com> jfw@ksr.com (John F. Woods) writes:
>ih96@sol.acs.unt.edu (Yu Zhi) writes:
>>Hi there. I got a question. I'm working under unix and have some fortran
>>program which I would like to call over and over again. So I decided to
>>write a c program and use execve() calls. But one thing made me mad is that
>>after the call of execl(), the control won't retrun to the c calling program.
>>I'm sure there some way to around this.
>
>The easiest way around it is to ensure that the program you call with execl()
>does not exist, thus enabling execl() to return to your program with an error
>code.
>
>execl() is *supposed* to work the way you see.  It *replaces* the current
>process image with a new program.
>
>It sounds like what you really want is "system()" (check your friendly
>neighborhood manual set).

How about:

main()
{
   if(fork()!=0)
   {
       execl(...);
   } 
   continue....


}


Ie, fork() creates 2 identical processes, and returns 0 to one
of them (the child), and the pid of the child to the other (the
parent).  What this does is fork(), then ask 'Am I the child?', if
so, execl().  Else, I'm the parent, and I want to continue doing
something else.

I believe this is what Yu Zhi wanted.



-- 
Adam G.
adamg@microware.com, or ...!uunet!mcrware!adamg
The above is not to be construed in any way as the official or unofficial
statements of Microware, or any Microware employees.
From: mike@pacsoft.com (Mike Stefanik)
Newsgroups: comp.lang.c
Subject: Re: How to randomly access files in C?
Date: 2 Sep 92 04:32:15 GMT
Organization: Pacific Software Group, Riverside, Ca.

In an article, fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>Some files (eg. stdin) may not be seekable, in which case you would probably
>have to store the last few lines in memory. However for most files,
>ftell() and fseek() should do what you want (RTFM ;-).

If portability is a concern, use fgetpos() and fsetpos().  The reason being
that the fseek() and ftell() functions use a signed long integer as the
offset -- which can be a problem with large files on 8 or 16 bit machines.

-- 
Mike Stefanik  mike@pacsoft.com  ...!uunet!pacsoft!mike
Pacific Software Group, Riverside, CA
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.c
Subject: Re: ANSI description for signal handling
Date: 1 Sep 1992 16:05:06 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <1992Sep1.020305.15064@thinkage.on.ca> atbowler@thinkage.on.ca (Alan Bowler) writes:
>  In the case of an implicit raise,
>you can only call signal() with the SAME signal number, and you can
>only get out of the handler by doing a return.

But the quoted passage also says that if you do a return from a handler
that was called due to SIGFPE, the behavior is undefined.  So, if SIGFPE is
raised implicitly, there's no way to get out of the handler!
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c
Subject: Re: why execve() call wouldn't return to the calling program?
Keywords: execve, unix, process
Date: 28 Aug 92 13:23:01 EDT

ih96@sol.acs.unt.edu (Yu Zhi) writes:
>Hi there. I got a question. I'm working under unix and have some fortran
>program which I would like to call over and over again. So I decided to
>write a c program and use execve() calls. But one thing made me mad is that
>after the call of execl(), the control won't retrun to the c calling program.
>I'm sure there some way to around this.

The easiest way around it is to ensure that the program you call with execl()
does not exist, thus enabling execl() to return to your program with an error
code.

execl() is *supposed* to work the way you see.  It *replaces* the current
process image with a new program.

It sounds like what you really want is "system()" (check your friendly
neighborhood manual set).
From: wsanders@ffeine.Sun.COM (Wiley Sanders)
Newsgroups: comp.lang.c
Subject: Re: Sun Spots recently sighted on Earth (was: Re: Simple C question)
Date: 25 Aug 1992 16:57:22 GMT
Organization: Tradeshow Tech Support
NNTP-Posting-Host: ffeine.corp.sun.com

There are three Sun C compilers for use with SunOS 4.1.2 and below:
1) The cc that ships with SunOS, the "familiar" Sun C compiler based
   on the PCC / BSD / etc. compiler that has traditionally shipped with
   SunOS.
2) The unbundled cc compiler. Not ANSI conformant.                  
3) The unbundled acc compiler. ANSI conformant.

2 and 3 come together on the same CD, and are optimized for the Sun
architecture.

With Solaris 2.0, no cc is provided. When you buy the unbundled 
compiler, there is no longer a separate "cc" and "acc" but flags
that switch the compiler between four modes:
(These are quotes from the man page):

a) ANSI        ANSI C plus Sun C compatibility  extensions,  with
               semantic  changes required by ANSI C.  Where Sun C
               and ANSI C specify  different  semantics  for  the
               same  construct,  the compiler will issue warnings
               about the conflict and use the ANSI C  interpreta-
               tion.

b) conformance Maximally conformant ANSI C, without Sun C  compa-
               tibility  extensions.   The  compiler  will reject
               programs that use non-ANSI C constructs.

c) Sun C       The compiled language includes all features compa-
               tible  with  (pre-ANSI) Sun C.  The compiler warns
               about all language constructs that have  differing
               behavior between Sun ANSI C and the old Sun C.

d) transition  ANSI  C  plus  Sun  C  compatibility   extensions,
               without  semantic  changes  required  by  ANSI  C.
               Where Sun C and ANSI C specify different semantics
               for  the  same  construct, the compiler will issue
               warnings about the conflict  and  use  the  Sun  C
               interpretation.  This is the default mode.

Hope this clears up any confusion.
Disclaimer: I am possessed by the Evil Demon Urrgh and all statements
in this article should be attributed to him and not to me.
--
"What a waste it is to lose one's mind, or not to
have a mind as being wasteful. How true that is."     -Dan Quayle
Newsgroups: comp.lang.c
From: ajg@controls.ccd.harris.com (Arnold Goldberg)
Subject: WATNED: C to Fortran Translator
Organization: Harris Controls and Compositions
Date: Thu, 3 Sep 1992 16:18:48 GMT

 
I'm looking for a translator (scripts or whatever) that would translate
a C .h file to something usable by Fortran.
 
I just need to be able to translate structures, not the code.
 
It has to handle nested structures.
 
 
thanks,
 
arnold
--
------------------------------------------------------------------------
Arnold Goldberg                            Email:  ajg@ccd.harris.com
Phone: (407)242-5051                       Snail:  Harris Corporation
Fax  : (407)242-4262                               407 John Rodes Blvd.
                                                   Melbourne, FL 32905
The opinions expressed are my own and do not in any way represent Harris 
------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: rob@guinness.eng.ohio-state.edu (Rob Carriere)
Subject: Re: True Portability?
Organization: The Ohio State University Dept of Electrical Engineering
Date: Fri, 4 Sep 1992 05:03:58 GMT

In article <1992Sep3.183152.29325@wam.umd.edu> krc@wam.umd.edu (Kevin R.
Coombes) writes: 
>krc@wam.umd.edu (Kevin R. Coombes) writes:
>>Both those files [MatLab .mat and TeX .dvi] are binary data files used by
>>the programs I mentioned. 
>>Clearly, they are portable, since implementations of the software for
>>different platforms can both use them. 
>Matlab is harder [than TeX] (and the documentation unavailable, since it's a
>commercial product) mainly because it must store floating point data.
>Each MAT file stores as its first (?) byte a code which identifies the
>machine on which the file was produced. I assume they handle portability
>in some grungy fashion that needs to know that information.

The format of the .mat file is actually explained exactly in the docs (look up
"save" in the reference section.)  It more or less works as you describe: each
variable is saved with a header that describes machine of origin (including FP
format), whether arrays are stored row major or column major, whether
precision is double or single, whether the data is numeric or text, number of
rows, number of cols, real or complex data.  So, yes, the format is portable
because the program is given enough information to retrieve the data in
arbitrarily grungy fashion.  :-)  And all that for about a factor of 2
reduction in size over ASCII (which you could've gotten out of compress...)

SR
---
From: sasghm@theseus.unx.sas.com (Gary Merrill)
Newsgroups: comp.lang.c
Subject: Re: Most difficult part of learning C?
Date: 26 Aug 92 14:08:56 GMT
Organization: SAS Institute Inc.
Originator: sasghm@theseus.unx.sas.com


In article <1992Aug26.124652.9509@alw.nih.gov>, sullivan@alw.nih.gov (Jim Sullivan) writes:
|> In article <9208251159.AA04122@ult4>, goldstei@cgi.com ("Morris Goldstein") writes:
|> |> I am conducting research for a little project concerning difficulties in
|> |> learning C and how to improve the teaching of C so as to circumvent these
|> |> problems.
|> |> 
|> |> When learning C, what things did you find the most confussing/difficult to
|> |> understand?
|> 
|> What else?... POINTERS!

Here's what else (though this does, I suppose, fall under the giant
umbrella of pointers as well):  multi-dimensional arrays.

I have taught classes in C programming a number of times and, even
once people think they are past pointers and arrays, the issues
of multi-dimensional arrays really throw them.  (This is, of
course [and I know I'm courting flames here], because there really
aren't multi-dimenisonal arrays in C -- it just looks like there
are.)  How to define them, how to initialize them, etc.  I never
use them myself, but people who feel the need to get up close
and personal with matrices seem to like them.

In addition, time is well spent on declarations in C -- beyond the
simplistic ones.  Functions returning pointers to functions taking
... as parameters and returning ...   You get the idea.  Just
learning to *read* C declarations correctly goes a long way to
having a good grasp of the language.  Beware of uncritically using
examples from books.  There frequently are mistakes.
-- 
Gary H. Merrill  [Principal Systems Developer, C Compiler Development]
SAS Institute Inc. / SAS Campus Dr. / Cary, NC  27513 / (919) 677-8000
sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm