这是我的代码
#include<stdio.h>
//program to check the validity of isbn no.
// valid isbn no if 1*d1+2*d2+3*d3+4*d4+5*d5+6*d6+7*d7+8*d8+9*d9+10*d10
// is divisible by 11
// where d(n) is the nth digit
// the first digit can be 10 denoted by X
int main()
{
char isbnNo[10],flag[50];
int sum=0;
printf("Enter the ISBN no. = ");
scanf("%s",isbnNo);
for(int i=0;i<10;i++)
{
if(isbnNo[0]=='X')
sum=10+sum;
sum=sum+((int)isbnNo[i]-48)*(i+1); //to convert string to int
}
if(sum%11==0)
flag[100]="The ISBN no. is valid";
else
flag[100]="The ISBN no. is not valid";
printf("%s",flag);
return 0;
}
据我所知,它应该可以正常工作而不会出现任何错误。 我想知道警告的含义以及如何纠正它
ISBNvalidity.c: In function 'main':
ISBNvalidity.c:20:14: warning: assignment to 'char' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
flag[100]="The ISBN no. is valid";
^
ISBNvalidity.c:22:14: warning: assignment to 'char' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
flag[100]="The ISBN no. is not valid";
^
输出是任何垃圾值。