'Trying to get the length of digits in c
I'm trying to understand why I am getting this error message.
error: data argument not used by format string [-Werror,-Wformat-extra-args]
printf("Enter card number: ", card_number);
here is the code that I'm trying to run the only difference between this and the code I'm copying is the name of the int.
#include <stdio.h>
int main ()
{
//Get card number from customer
int card_number;
int length = 0;
printf("Enter card number: ", card_number);
scanf("%d", &card_number);
while(card_number != 0)
{
card_number /= 10;
++length;
}
printf("Digits: %d", length);
return 0;
}
I'm trying to use this to check if the length of the card_number entered is equal to a certain value. I haven't coded anything else due to this error. If I can understand better why I'm getting this error it would be greatly appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
