I'm having trouble setting up the code for a function. The error message show: conflicting types.
So I think it's because my return type is different from the value in the parameter. So I was wondering if it's possible to have different types of values in the parameter and how to fix this code.
//prompt user to enter the credit card number and print it on screen long get_credit() { long credit_number = get_long("Number: "); //printf("Number: %li\n",credit_number); //debugging return credit_number; } //digits lengther int get_digit(long credit_number) { long credit = credit_number; //length of the number of digits given by the user int length = 0; while(credit != 0) { credit = credit/10 ; length ++ ; } return length; }
This is the error message it's showing me.
credit_v2.c:154:5: error: conflicting types for 'get_digit' int get_digit(long credit_number) ^ credit_v2.c:7:5: note: previous declaration is here int get_digit(void); //calculate the number of digits ^
Again, thank you guys for all the help!
https://stackoverflow.com/questions/65433435/how-can-i-pass-a-long-type-value-into-the-parameter-of-a-function-with-integer-a December 24, 2020 at 10:59AM
没有评论:
发表评论