kirti desai
kirti desai

Reputation: 33

Error while compiling : "invalid operands to binary / (have ‘short int *’ and ‘int’)"

short int cipher[50],len;
while(cipher != 0)
{  
    cipher=cipher/10;
    ++len;
}

Need to count number of digits provided by user.

 error: invalid operands to binary / (have ‘short int *’ and ‘int’)
           cipher=cipher/10;

Upvotes: 3

Views: 129

Answers (1)

Armali
Armali

Reputation: 19375

As gsamaras noted, you defined cipher as an array of 50 short ints. Presumably you want only one number, so you'd define it e. g. as long long cipher; (C is not COBOL or something where one has to specify the number of digits). And don't forget to initialize len.

Upvotes: 2

Related Questions