|
*Subject: Re: First C program
*From: Jevgeni Astanovski <Jevgeni.Astanovski@xxxxxxxxxxxxx>
*Date: Thu, 3 Apr 2014 10:53:31 +0000
One more thing.
You write:
memcpy (sfrcd.S01FUNC , " ", 2 );
memcpy (sfrcd.S01APFILE, " ", 10 );
memcpy (sfrcd.S01APLIB , " ", 10 );
memcpy (sfrcd.S01APACCP, " ", 1 );
memcpy (sfrcd.S01APUNIQ, " ", 1 );
memcpy (sfrcd.S01APSELO, " ", 1 );
memcpy (sfrcd.S01APFTYP, " ", 1 );
memcpy (sfrcd.S01APJOIN, " ", 1 );
memcpy (sfrcd.S01APKEYO, " ", 1 );
memcpy (sfrcd.S01APKSEQ, pfrcd.APKSEQ, 1 );
memcpy (sfrcd.S01APKSIN, pfrcd.APKSIN, 1 );
memcpy (sfrcd.S01APKEYF, pfrcd.APKEYF, 10 );
My advise is to do it another way:
memset (&sfrcd, ' ', sizeof(sfrcd)) ;
memcpy (sfrcd.S01APKSEQ, pfrcd.APKSEQ, 1 );
memcpy (sfrcd.S01APKSIN, pfrcd.APKSIN, 1 );
memcpy (sfrcd.S01APKEYF, pfrcd.APKEYF, 10 );
C differs from other languages - it does not initialize variables
on declarations in general, and structures - in particular.
So by setting full structure to spaces and then assigning/initializing
only specific fields you make your program at least shorter. But also morereliable.
Of course you must take care of numeric fields -accessing.
you have to explicitly assign valid numeric values to them before
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.