Also die Definition eines Struct in C51 laut Handbuch würde fast genauso
aussehen wie du es gemacht hast nur ohne das typedef und das File:
1 | struct afile
|
2 | {
|
3 | unsigned long start_cluster; // Sectorpointer to the first sector of the first datacluster of the file.
|
4 | unsigned long cluster_pointer; // Pointer to the cluster which is edited at the moment.
|
5 | unsigned char sector_index; // The sector which is edited at the moment (cluster_pointer + sector_index).
|
6 | unsigned int byte_index; // The bytelocation within the current sector (cluster_pointer + sector_index + byte_index).
|
7 | unsigned char mode; // mode of fileoperation (read,write)
|
8 | unsigned long filesize; // the size of the opend file in bytes.
|
9 | unsigned long fileposition; // pointer to a character within the file 0 < fileposition < filesize
|
10 | unsigned long sector_in_buffer; // the last sector read, wich is still in the sectorbuffer.
|
11 | unsigned long directory_sector; // the sectorposition where the directoryentry has been made.
|
12 | unsigned char directory_index; // the index to the directoryentry within the specified sector.
|
13 | unsigned char attribute; // the attribute of the file opened.
|
14 | };
|
Und die Initialisierung einer Variable samt einem Datensatz würde für
dein Beispiel folgendermassen aussehen:
1 | struct afile data info[1]={1,2,"3",4,"5",6,7,8,9,"10","11"};
|
Dabei steht data nur für den Speicherbereich in dem die Variable
angelegt wird. Und die 11 Werte hintendran entsprechen deinen 11 Feldern
des Struct.
Ich habe bisher selber noch nie einen Struct verwendet, weshalb diese
Informationen alleine aus dem Handbuch stammen. Aber ich hoffe, ich habe
mich nirgends verschrieben. ;)
Ciao,
Rainer