1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-24 15:31:17 +00:00
C02/py65/structs.c02

57 lines
1.0 KiB
Plaintext
Raw Normal View History

2018-03-08 19:35:00 +00:00
/**********************************************
* 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;
2018-03-09 01:07:31 +00:00
for (i = 0; i<=@srcrec.data; i++)
2018-03-08 19:35:00 +00:00
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);
2018-03-09 01:07:31 +00:00
memcpy(@srcrec, &srcrec);
2018-03-08 19:35:00 +00:00
prtdst();
goto exit;
//Print Destination Record
void prtdst() {
puts("REC.NAME="); putln(&dstrec.name);
puts("REC.INDEX="); putdec(dstrec.index); newlin();
puts("REC.DATA={");
2018-03-09 01:07:31 +00:00
for (i = 0; i<@dstrec.data; i++) {
2018-03-08 19:35:00 +00:00
if (i) putc(',');
putdec(dstrec.data[i]);
}
putln("}");
newlin();
}