1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 16:34:15 +00:00
C02/py65/structs.c02
2018-03-08 20:07:31 -05:00

57 lines
1.0 KiB
Plaintext

/**********************************************
* STRINGS - Demonstrate string.h02 functions *
**********************************************/
#include <py65.h02>
#include <stdio.h02>
#include <stdiox.h02>
#include <stdlib.h02>
#include <memory.h02>
#include <string.h02>
char d, i;
//Define Structure
struct record {
char name[8];
char index;
data[128];
};
//Declare Structure Variable
struct record srcrec;
struct record dstrec;
main:
//Set Structure Members
strdst(&srcrec.name); strcpy("RECNAME");
srcrec.index = 1;
for (i = 0; i<=@srcrec.data; i++)
srcrec.data[i] = i;
//Clear Destination Record
for (i=0; i<140; i++)
dstrec[i] = 0;
prtdst();
//Copy Source Record into Destination Record
memdst(&dstrec);
memcpy(@srcrec, &srcrec);
prtdst();
goto exit;
//Print Destination Record
void prtdst() {
puts("REC.NAME="); putln(&dstrec.name);
puts("REC.INDEX="); putdec(dstrec.index); newlin();
puts("REC.DATA={");
for (i = 0; i<@dstrec.data; i++) {
if (i) putc(',');
putdec(dstrec.data[i]);
}
putln("}");
newlin();
}