Copie dans un tableux

Fermé
xtimas Messages postés 11 Date d'inscription mardi 20 avril 2010 Statut Membre Dernière intervention 15 juin 2011 - 23 juin 2010 à 15:25
xtimas Messages postés 11 Date d'inscription mardi 20 avril 2010 Statut Membre Dernière intervention 15 juin 2011 - 23 juin 2010 à 15:37
Bonjour,
je débute en C, et je veux copier les élements de ce tab2[4]={0x1100,0x3322,0x5544,0x7766}; dans un autre tableau
tab1[8]={0x00, 0x11, 0x22; 0x33, 0x44, 0x55, 0x66, 0x77};

j'ai écris ce code mais je n'arrive pas à intégrer une autre boucle pour reconstruire tab1:
pouvez vous m'aider svp?

#include <stdio.h>
#include <conio.h>
   
int main()
{
    int i, j;
      j=0; 
unsigned int tab1[8];
unsigned int tab2[4]={0x1100,0x3322,0x5544,0x7766};
for( i = 0; i < 4; i++ )
     {
     	tab1[j]= tab2[i] % 0x100; 
		printf("\n tab(j)   : %.2lX", tab1[j]);
	tab1[j+1]= tab2[i] / 0x100;
		printf("\n tab(j+1) : %.2lX", tab1[j+1]);
	}
	
  getch();
}
A voir également:

1 réponse

Neliel Messages postés 6146 Date d'inscription jeudi 9 juillet 2009 Statut Contributeur Dernière intervention 20 mars 2017 1 692
Modifié par Neliel le 23/06/2010 à 15:29
Bonjour,

  
for( i = 0; i < 4; i++ )  
     {  
      tab1[j]= tab2[i] % 0x100;   
  printf("\n tab(j)   : %.2lX", tab1[j]);  
 tab1[j+1]= tab2[i] / 0x100;  
  printf("\n tab(j+1) : %.2lX", tab1[j+1]);  

        j = j + 2;  
 }  


--
"Trotti Trotta, Monsieur P, il y a des anges qui veulent un bisou..."
"Même les joujou de Monsieur P ont besoin de joujou"
0
xtimas Messages postés 11 Date d'inscription mardi 20 avril 2010 Statut Membre Dernière intervention 15 juin 2011
23 juin 2010 à 15:37
merci, c'était simple ( et embarrassant ) :))
0