문제

The following is the code which I typed in c

unsigned long long int Je=23; 
int col=2,row=2; 
void mod(unsigned long long int mat1[][col],unsigned long long int mat2[][col],int r) 
{
    int i,j;
    for(i=0;i<r;i++)
        for(j=0;j<col;j++)
        {
            mat1[i][j]=mat2[i][j]%Je;
            printf("Value mat1=%u mat2=%u Je=%u\n",mat1[i][j],mat2[i][j],Je);
        } 
}

I call this function with the following matrix

t1[2][2]={1036,1090,1526,1472};
mod(t2,t1,row);

But in the console screen I get the following results for the "printf" statement I included inside the function definition

Value mat1=5 mat2=0 Je=1036
Value mat1=2 mat2=0 Je=1090
Value mat1=16 mat2=0 Je=1526
Value mat1=9 mat2=0 Je=1472

How come the values are printed like this? I am using Dev Cpp compiler.

도움이 되었습니까?

해결책

The format specifiers "%u" in the printf statement are incorrect. For an unsigned long long, the specifier should be "%llu"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top