Article View: fr.comp.lang.c
Article #64Re: TRe: Structure et tableau en C ?
From: Horst Kraemer
Date: Sun, 06 Feb 2005 18:31
Date: Sun, 06 Feb 2005 18:31
81 lines
2708 bytes
2708 bytes
"Thierry59" <thierry59__no_spam@tiscali.fr> wrote:
> Merci pour vos reponses, mais je n'ai pas su me depatoullier.... je met un
> exemple....
>
> // Note 1: la structure definissant une partie de la structure de la FAT....
> (boot secteur....) : Declaration global
> struct FatBootsector
> {
> unsigned char jump[3];
> unsigned char oem_id[8];
> unsigned short bytes_per_sector;
> unsigned char sectors_per_cluster;
> unsigned short num_boot_sectors;
> ......... etc .........
> }; /* 512 bytes total */
V�rifier que
sizeof (struct FatBootsector) == 512
> // Note 2: Fonction qui permet de visualiser les infos du boot secteur d'un
> disque FAT16 par exemple:
void ShowTable(struct FatBootsector *MBR)
{
printf("Oem %.8s\n",MBR->oem_id);
}
>
> // Note 3: Programme principal par Ex....
> main()
> {
> unsigned char Tab[512];
>
> ReadFat(2,Tab) // je recup le boot secteur.....
> ShowTable(Tab); // affichage des indos....
remplacer par
struct FatBootsector Fat;
if (sizeof Fat != 512)
{
fprintf(stderr,"sorry, sizeof Fat is %d\n",
(int)sizeof Fat);
exit(EXIT_FAILURE);
}
ReadFat(2,(unsigned char*)&Fat)
ShowTable(&Fat);
> }
Une m�thode �quivalente serait
unsigned char Tab[512];
if (sizeof (struct FatBootsector) != 512)
{
fprintf(stderr,
"sorry, sizeof(struct FatBootsector) is %d\n",
(int)sizeof (struct FatBootsector));
exit(EXIT_FAILURE);
}
ReadFat(2,Tab)
ShowTable((struct FatBootsector*)Tab);
toujours avec la d�claration
ShowTable(struct FatBootsector *MBR)
--
Horst
Technical Details
Message-ID:
<5jnc01d8fgjc3gljjuf4rhs54h2l16i212@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mailReferences:
<ctu7go$9cu$1@news.tiscali.fr> <mn.2ab77d52fdfd0d34.15512@YOURBRAnoos.fr> <cu5k8g$jal$1@news.tiscali.fr>Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,807078fb0437ad92 X-Google-Thread: 102e15,9f3075a9014ccc0b X-Google-Attributes: gidf9822,gid102e15,public X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Horst Kraemer <h-kraemer@lycos.de> Newsgroups: fr.comp.lang.c,fr.comp.developpement Subject: Re: TRe: Structure et tableau en C ? Date: Sun, 06 Feb 2005 19:31:09 +0100 Lines: 82 Message-ID: <5jnc01d8fgjc3gljjuf4rhs54h2l16i212@4ax.com> References: <ctu7go$9cu$1@news.tiscali.fr> <mn.2ab77d52fdfd0d34.15512@YOURBRAnoos.fr> <cu5k8g$jal$1@news.tiscali.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net +2ts+XDf6CGSe4GZEyNgKADOFZ3jD4pUMiMqu/jvzHk8w08OA= X-Newsreader: Forte Agent 2.0/32.652