Merci encore, mais un pb subsiste : j'ai du mal a mettre le tableau ainsi crée en argument d'une autre fonction, ca donne :
--------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char lireligne(char s[])
{
int c,i;
i=0;
printf("saisir la ligne\n" );
while ((c=getchar())!='\n'
s[i++]=c;
if (c == '\n'
s[i++] = c;
s[i] = '\0';
}
/*************************************************
*****************************/
int * creer_tableau(int * Tab , int Lignes , int Colonnes)
{
return realloc(Tab, Lignes * Colonnes * sizeof(int));
}
/*************************************************
*****************************/
void recherche_fonction( char str[], char str2[], int k, int * tab[][])
{
int i=0,j=0,m=0,n=0;
int * MonTableau = NULL;
int nb_lignes = 1;
int nb_colonnes = 4;
char * pch;
MonTableau = creer_tableau(MonTableau, nb_lignes, nb_colonnes);
pch=strstr(str,str2);
printf("%s\n",pch);
for (n = 0; n < nb_colonnes; n++)
{
if (pch==NULL) {
MonTableau[n * nb_colonnes + k] = -1;
}
else {
MonTableau[k * nb_colonnes + n] = pch-str+1;
pch = strstr (pch+3,str2);
nb_lignes++;
printf("on augmente" );
MonTableau = creer_tableau(MonTableau, nb_lignes, nb_colonnes);
}
}
/* impression tableau */
for (j = 0; i < nb_colonnes; j++)
{
for (i = 0; i < nb_lignes ; i++)
{
printf("%d\t",MonTableau[i * nb_colonnes + j]);
}
}
/* fin impression tableau */
}
/******************************************************************************/
void main(void)
{
char ligne[100];
char ligne2[3];
int * MonTableau = NULL;
int i=0,j=0;
int n;
lireligne(ligne);
recherche_fonction(ligne , "cos" , 0 , MonTableau);
//MonTableau[3 * nb_colonnes + 5] = 20; /* pour acceder à MonTableau[3][5] */
//nb_lignes = 30;
//MonTableau = creer_tableau(MonTableau, nb_lignes, nb_colonnes);
/* nouvelle taille 30 * 20 - Attention à ne pas toucher au nombre de colonnes (la largeur)*/
}
--------------------
Je comprends pas pourquoi ca me sort un tableau infini ?
---------------
Wigga with Attitude.