pfdm  | Code :
 - #include <stdio.h>
 - #include <stdlib.h>
 - #include <string.h>
 - #include <math.h>
 - /*---------------------------------------------------------------------------------------------------------------------------------*/
 - void main()
 - {
 - 	int j=0;
 - 	int i=0;
 - 	char *filename = "toto.dat";
 - 	char numberC[20];
 - 	double mat[4][3];
 - 	double number = 0;
 - 	int coef = 0,line = 0;
 - 	FILE *file = NULL,*file2 = NULL;
 - 	int c =0;
 - 	int numberofflines=0;
 - 	double *cologn;
 - 	double comp;
 - 	int l=0,k=0;
 - 	double matcomp[5]={1,2,3,4,5};
 - 	/****************************************/
 - 	file = fopen (filename,"w" );
 - 	if (file==NULL)
 - 	{
 -   printf("cannot open file '%s'\n",filename);
 -   exit(0);
 - 	}
 - 	fprintf(file,"%f %f %f\n", 3.6 , 4.8 , 45.876);
 - 	fprintf(file,"%f %f %f\n", 1.6 , 4.5 , 89.0);
 -     fprintf(file,"%f %f %f\n", 7.63 , 1.2 , 0.56);
 - 	fprintf(file,"%f %f %f\n", 5.7 , 8.8 , 0.5786);
 - 	fclose(file);
 - 	/*******************************************************/
 - 	file2 = fopen(filename,"r" );
 - 	if (file=NULL)
 - 	{
 -   printf("cannot open file '%s'\n",filename);
 -   exit(0);
 - 	}
 - 	/*
 - 	while( (c=fgetc(file2))!=EOF)
 - 	{
 -   if (c=='\n') numberofflines++;
 -   printf(" nombre de lignes :%d\n",numberofflines);
 - 	}
 - 
 - 	******************************************************/
 - 	rewind(file2);
 -     cologn=mat[0];
 - 	while( (c=fgetc(file2))!=EOF)
 - 	{
 -   if ( (c!=' ') && (c != '\n'))
 -   {
 -   	numberC[j++]=c;
 -   }
 -   else
 -   {
 -   	numberC[j]='\0';
 -   	number = atof (numberC);
 -   	*(cologn)=number;
 -   	/*mat[line][coef]=number;*/
 -   	/*printf("number %f\n", number);*/
 -   }
 -   if (c==' ')
 -   {
 -   	cologn++;
 -   	j = 0;
 -   }
 -   else if (c=='\n')
 -   {
 -   	cologn++;
 -   	j=0;
 -   }
 - 	}
 - 	fclose (file2);
 - 	/******************************************************/
 - 	for(i=0;i<4;i++)
 - 	{
 -   for( j=0;j<3;j++)
 -   {
 -   	printf("le nombre de la ligne %d et colonne %d est %f\n",i+1,j+1,mat[i][j]);
 -   }
 - 	}
 - 	/********************************************************/
 - 	comp=mat[0][0];
 - 	cologn=mat[0];
 - 	for(k=0;k<5;k++)
 - 	{
 -   while (*cologn != number)
 -   {
 -   	if	(comp < *cologn)
 -   	{
 -     for(l=0;l<k;l++)
 -     {
 -     	printf(" matcomp%f",matcomp[l]);
 -     	if (comp != matcomp[l])
 -     	{
 -       comp=*(cologn);
 -       printf("le nouvo %f\n",comp);
 -     	}
 -     }
 -   	}
 -   	cologn++;
 -   	printf("%f\n",*cologn);
 -   }
 -   printf(" le plus grd %f\n",comp);
 -   matcomp[k]=comp ;
 - 	}
 - 	for (i=0;i<4;i++)
 - 	{
 -   printf("%f\n",matcomp[i]);
 - 	}
 - }
 
  |  
 
     malgre le fait que j'ai definit matcomp au debut,il me retourne toujours la mem valeur.
 merci de votre aide
  
     |