=========================================================================
 
INFO-ATARI16 Digest         Wed, 20 Dec 89       Volume 89 : Issue  840
 
Today's Topics:
                              C question
         more on strncpy (was re: laser c question) (2 msgs)
            More Portfolio Ads, with a curious feature...
                  USENET -> GEnie uplink now working
----------------------------------------------------------------------
 
Date: 18 Dec 89 12:49:34 GMT
From: nis!pwcs!stag!daemon@UMN-CS.CS.UMN.EDU  (John Stanley)
Subject: C question
Message-ID: <1989Dec18.124934.1487@stag.UUCP>
 
[S61304@PRIME-A.POLY-SOUTH-WEST.AC.UK (Rat) writes...]
 
> Why wont Sozobon, Lattice or any other C compiler I've tried compile the
> following, from K&R?
>
> main()
>      $
>      char fred[] = "Some string constant";
>      <rest of routine>
>
>
> This has been confusing me for a while, as K&R (surely correct!) would
> seem to indicate that this is indeed permissible!
 
 (Assuming that the '$' character in the line after main() is really
suppost to be a '?' character on your machine and just got garbled...??)
 
  Can you please tell me where in K&R this example is used?
 
  The problem is because you can't assign a string to an unknown size
array at runtime (at least not that way)...  The array you give there
needs to be defined with:
 
        static char fred[] = "Some string constant";
 
  Defining the array as static tells the compiler you want the array to
be created-and-initialized, as-shown, at compile-time.
 
  To assign the array at runtime, you've got a number of options, but the
easiest way is:
 
        main()
                ?
                char fred[22];
 
                strcpy(fred, "Some string constant");
                <rest of routine>
                ?
 
---
John Stanley <dynasoft!john@stag.UUCP>
Software Consultant / Dynasoft Systems
 
------------------------------
 
Date: 18 Dec 89 12:49:32 GMT
From: nis!pwcs!stag!daemon@UMN-CS.CS.UMN.EDU  (John Stanley)
Subject: more on strncpy (was re: laser c question)
Message-ID: <1989Dec18.124932.1486@stag.UUCP>
 
[kirkenda@.cs.pdx.edu (Steve Kirkendall) writes...]
>
> In article <1870@calvin.cs.mcgill.ca> depeche@calvin.cs.mcgill.ca (Sam Alan
 EZUST) writes:
>>someone already sent me dlibs memcpy which I believe is what is used
>>in Sozobon.... However, I don't have an assembler and am not too
>>much of an expert in it anyway, so I couldn't get it installed on
>>my system without help.
>
> Okay, here's one in C:
>
>       memcpy(dest, src, count)
>               register char   *dest;  /* destination address */
>               register char   *src;   /* source address */
>               register int    count;  /* number of bytes to copy */
>       ?
>               while (--count >= 0)
>                       *dest++ = *src++;
>       ?
>
> This can copy up to 32767 bytes at a time.  It isn't very fast, though.
 
  Actualy, it can copy up to 65535 bytes if you change:
 
                while (--count >= 0)
        into
                while (count-- != 0)
 
  While the parameter passed to memcpy is usualy documented to be just an
int, it's not uncommon for versions of memcpy to treat the count variable
as an unsigned integer instead which doubles the amount to memory that
can be moved with a single call...
 
  (Before you use this, be sure your code isn't going to have to deal
with copying negative numbers of bytes... only 1/2 :~)
 
---
John Stanley <dynasoft!john@stag.UUCP>
Software Consultant / Dynasoft Systems
 
------------------------------
 
Date: 18 Dec 89 12:49:47 GMT
From: nis!pwcs!stag!daemon@UMN-CS.CS.UMN.EDU  (John Stanley)
Subject: more on strncpy (was re: laser c question)
Message-ID: <1989Dec18.124947.1535@stag.UUCP>
 
[depeche@quiche.cs.mcgill.ca (Sam Alan EZUST) writes...]
[.. responding to email I sent to him ..]
 
> :   Alternately, does Lazer C allow copying structures using a simple
> : assignment?  <struct2> = <struct1>;  If so, what I've ocassionaly used in
> : situations like yours is to define a struct containing the array and
> : moved copys of the array arround by just using assignments...
>
> that's a good idea. I should try it. I didn't think it was possible though,
> as struct names are just pointers to memory locations of data, just
> like arrays,
 
  Nope.  A struct name is the name of a structure.  It is -not- a pointer
even though it has an address that you can obtain by using: &structname
(Note that the address you obtain (unless you cast it or store it into a
pointer of some other type) still "knows" that it's pointing to a struct
so if you use *(&structname) it references the original structure, not
just the 1st byte in the structure.
 
  *(unsigned char *)(&structname) would give you the structures 1st byte...
 
> and you can address the 5th byte of a structure with
> *(structname+5) just like arrays.
 
  Nope....  *(structname+5) is an illegal construct.  You can't increment
a structure itself and contrary to your assumption, a structname is -not-
the same as a pointer to a structure.
 
  On the other hand, ((&structname)+5) (which is different) would point
to a location 5 STRUCTURES higher in memory than &structname.  In C, any
addition to a pointer is taken as increasing the pointer by (the value
added multiplied by the size of the object being pointed at (in this case
a structure)).  This sometimes causes confuses because many people
normaly only deal with arrarys of characters (so the sizeof object == 1).
 
  Example:
 
        struct foo
                ?
                int foo_1[32][100];
                ?;
 
        foocpy()
                ?
                struct foo src, dst;
 
                /* if your compiler allows structure assignment, */
                /* the next line should copy an array 32 x 100   */
                /* integers long with a single assignment...     */
 
                dst = src;
 
                /* individual elements would be referenced as... */
 
                src.foo_1[23][7] = 2619;
                ?
 
> you are exactly right. However, I got it working now via the brute-force
> loop-of-assign statements. If I can get dlibs installed properly on
> Laser C (and I am having trouble, as you will soon see in one of
> my messages posted on c-s-a-st which I posted today), I will then
> translate them all into memcpy's.
 
  Good luck.  You may still want to consider using struct assignments
since I've been told Lazer-C does support them...
 
> :   .. although, it would be a real-good-idea if you posted a note on the
> : net mentioning that strncpy doesn't move <n> bytes so other beginning
> : programmers who see your message won't think that it's a correct
> : substitution....
>
> ok.. I shall. Thanks for your help/reply!!
 
  You're welcome...
 
> --
> S. Alan Ezust                                   depeche@calvin.cs.mcgill.ca
> McGill University Department of Computer Science - Montreal, Quebec, Canada
 
---
John Stanley <dynasoft!john@stag.UUCP>
Software Consultant / Dynasoft Systems
 
------------------------------
 
Date: 20 Dec 89 02:19:47 GMT
From: nis!pwcs!stag!daemon@UMN-CS.CS.UMN.EDU  (John Stanley)
Subject: More Portfolio Ads, with a curious feature...
Message-ID: <1989Dec20.021947.6026@stag.UUCP>
 
[gl8f@bessel.acc.Virginia.EDU (Greg Lindahl) writes...]
[.. talking about an ad for the Portfolio ..]
 
> However, I noticed something quite strange -- the display is simulated
> because you can't take a photo of a LCD display...
 
  Why tell people something like that?  You -can- take a picture of an
LCD display.  Why would you think otherwise?  (Yes, you have to get the
lighting right, but that's true of many photo subjects.  It's certanly
not "impossible"...)
 
> but the font used is proportionately spaced!
 
  This, on the other hand is a pretty good reason for thinking it's a
"simulated" screen...  :~)
 
---
John Stanley <dynasoft!john@stag.UUCP>
Software Consultant / Dynasoft Systems
 
------------------------------
 
Date: 19 Dec 89 17:17:34 GMT
From: thelake!steve@UMN-CS.CS.UMN.EDU  (Steve Yelvington)
Subject: USENET -> GEnie uplink now working
Message-ID: <1119891117345517@thelake.UUCP>
 
In article <15097@well.UUCP>,
     dsmall@well.UUCP (David Small) writes ...
 
(lots of stuff about Usenet <--> GEnie link.)
 
>       Systems like Compuserve and BIX could also fairly easily be done,
>now that the methodology is hacked through; also, other areas on GEnie are
>expressing great interest in having a USENET uplink. Basically, folks,
>USENET is perceived as the place where the people who know what they're
>doing post notes.
 
I don't think any Usenet news is available on Compu$erve, but it already
has an e-mail link to the Internet via Ohio State University. In theory,
e-mail to 71234,567 would be addressed to
 
  71234.567@compuserve.com
 
    or (from BITnet or other balky mail sites)
 
  71234.567%compuserve.com@saqqara.cis.ohio-state.edu
 
Note that the comma in the CIS userid has been changed to a dot in order
to meet RFC822 standards.
 
From Compu$erve to the Internet, it's
 
    >internet:user@host.domain
 
John Chew <poslfit@gpu.UTCS.UToronto.CA> maintains a list of internetwork
E-mail methods and posts it monthly to comp.mail.misc and
news.newusers.questions.
 
Last I heard, Delphi was carrying the Usenet rec.humor.funny newsgroup
(with Brad Templeton's blessing). I don't think it has hooked e-mail into
the free world, even though it would be quite easy -- plenty of other VMS
sites have done so. It does exchange e-mail with other commercial
services.
 
BIX is not, to my knowledge, e-mail accessible from the Internet and UUCP.
 
However, Jefferson Software in Phoenix (the Modula-2 folks where kbad used
to work) has developed a program for the ST that allows the transfer of
BIX public conferences into RFC1036 (Usenet news) format, stored in a
standard Usenet batchfile, and vice versa.
 
It currently is being used to internetwork BIX with several Citadel/STadel
BBS network discussion topics (rooms). I think the software is capable of
dumping Usenet news into BIX, and vice versa.
 
--
   Steve Yelvington at the (frozen enough to skate!) lake in Minnesota
   UUCP: ... pwcs.StPaul.GOV!stag!thelake!steve
 
------------------------------
 
End of INFO-ATARI16 Digest V89 Issue #840
*****************************************