0

少し問題があります。関数で使用される変数「posLigne」に取りたかった。ここにあります

     #include <stdio.h>
     #include <stdlib.h>
     #include <string.h>
     #define TAILLE_VIDE 30
     #define TAILLE_MAX 1000
#include <ctype.h>
int ar(char mot);
static int compare (void const *a, void const *b);
void indexation(FILE *f,char tChar[][100],char filename[],int *posLigne);
int motVide(char *mot);

    int main()
    {
    FILE *f=NULL;
    int posLigne=1;
    f=fopen("test.txt","r+");
int i;
char tChar[100][100];
char X[100][100];
int maju[100];
indexation(f,tChar,"test.txt",&posLigne);
charaff(tChar,7);
printf("%d",pos(tChar[1]));



    return 0;
}
void indexation(FILE *f,char tChar[][100],char filename[],int *posLigne)
{
    char nbr[100]="";
    int i=0,j=0,l=1,k=0;
    char ligne[TAILLE_MAX]="";
    char mot[100]="";
    while (fgets(ligne,TAILLE_MAX,f))
    {
            i=0;
            while (ligne[i]!='\0')
            {




memset (mot, 0, sizeof (mot));

    while (!(ar(ligne[i])))
    {

        mot[k]=ligne[i];
        k++;i++;
    }
        k=0;

//    if (!(motVide((mot))))
if(!motVide(mot))
        {
            strcat(tChar[j],mot);
            strcat(tChar[j]," ");
            strcat(tChar[j],filename);
            strcat(tChar[j]," ");
            sprintf(nbr,"%d",l);
            strcat(tChar[j],nbr);
            strcat(tChar[j]," ");
            sprintf(nbr,"%d",*posLigne);
            strcat(tChar[j],nbr);
            *posLigne++;
            j++;



        }
        i++;
    }
    l++;
    }
}

変数「posLigne」のみに焦点を当てます。ローカル変数として使用したい場合は、完璧に機能します。しかし、ポインターを使用して参照渡ししたい場合、大きな数値が表示されます。

ありがとう、良い一日を

4

2 に答える 2