Reference 指针不';我不想在C中通过引用传递

Reference 指针不';我不想在C中通过引用传递,reference,Reference,我只是有个小问题。我想使用函数中使用的变量“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 (voi

我只是有个小问题。我想使用函数中使用的变量“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++;
    }
}
#包括
#包括
#包括
#定义尾管,参见第30节
#定义TAILLE_MAX 1000
#包括
int-ar(char-mot);
静态整数比较(无效常数*a,无效常数*b);
无效索引(文件*f,字符tChar[][100],字符文件名[],int*posLigne);
int motVide(字符*mot);
int main()
{
文件*f=NULL;
int-posLigne=1;
f=fopen(“test.txt”、“r+”);
int i;
char tChar[100][100];
字符X[100][100];
int maju[100];
指数化(f、tChar、test.txt和posLigne);
查拉夫(tChar,7);
printf(“%d”,位置(tChar[1]);
返回0;
}
无效索引(文件*f,字符tChar[][100],字符文件名[],int*posLigne)
{
字符编号[100]=“”;
int i=0,j=0,l=1,k=0;
字符对齐[TAILLE_MAX]=“”;
char mot[100]=“”;
而(fgets(直线、直线、最大、f))
{
i=0;
while(ligne[i]!='\0')
{
memset(mot,0,sizeof(mot));
而(!(ar(ligne[i]))
{
mot[k]=ligne[i];
k++;i++;
}
k=0;
//如果(!(motVide((mot)))
如果(!motVide(mot))
{
strcat(tChar[j],交通运输部);
strcat(tChar[j],”);
strcat(tChar[j],文件名);
strcat(tChar[j],”);
sprintf(丁腈橡胶,“%d”,l);
strcat(tChar[j],nbr);
strcat(tChar[j],”);
sprintf(丁腈橡胶,“%d”,*posLigne);
strcat(tChar[j],nbr);
*posLigne++;
j++;
}
i++;
}
l++;
}
}
只关注变量“posLigne”,当我想将其用作局部变量时,它工作得非常完美。但当我想使用指针通过引用传递时,它会显示大数字

谢谢您,祝您今天愉快

您的线路

*posLigne++;
…可能不会像你想的那样。由于,它将相当于

*(posLigne++);
…这将更改指针,而不是指向的值。要实际增加值,需要使用parentese

(*posLigne)++;

这是因为
*posLigne++

试试
(*posLigne)+