Hello I'm getting an error when i try to pass a char through to a function. here is my code.
variable
char *temp;
Prototype
int checkIfUniqueCourseNo(char,int);
Call
checkIfUniqueCourseNo(temp,k);
and my error
warning: improper pointer/integer combination: arg #1
Im new to C so go easy on me :)
Your function accepts a char
; you are trying to pass in a char*
.
To fix this you need to dereference your pointer to obtain the character that it points to, so that your function receives the type of argument it expects:
checkIfUniqueCourseNo(*temp,k);
If the function excepts char
, you should dereference the pointer:
checkIfUniqueCourseNo(*temp,k);
// ^ pass the char addressed by temp
Your variable is a char*
(char pointer), but the function takes a char
(not a pointer).
If you want to pass the contents of temp to the function, use checkIfUniqueCourseNo(*temp, k)
. If you really do want to pass the pointer itself, declare the function as
int checkIfUniqueCourseNo(char*,int);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.