I have a code to implement a stack using array, here the complete code : here
The case is why I cannot to push more than one character, but
only one character?
but I've been clicking some variables are initialized using a struct
for her push
some characters in the form of an array:
struct stackMhs {
char nama[10];
char npm[10];
char telp[10];
int size;
};
struct stackMhs stackMhsbaru;
This is the push()
function with a parameter which will be the contents of data in the function main()
:
void push(char nm, char np, char tel) {
if(stackMhsbaru.size != 10) {
stackMhsbaru.nama[stackMhsbaru.size + 1] = nm;
stackMhsbaru.npm[stackMhsbaru.size + 1] = np;
stackMhsbaru.telp[stackMhsbaru.size + 1] = tel;
stackMhsbaru.size++;
}
else {
printf("stack is full!");
}
}
The problem is when I use '
to fill data is only one character at the push()
function like push('a','b','c');
when at compile no errors, but when I use "
such as push("aa","bb","cc");
when at compile error occurs:
main.c: In function 'main':
main.c:60:6: warning: passing argument 1 of 'push' makes integer from pointer without a cast [-Wint-conversion]
push("aa", "bb", "cc");
^
main.c:23:6: note: expected 'char' but argument is of type 'char *'
void push(char nm, char np, char tel) {
^
main.c:60:12: warning: passing argument 2 of 'push' makes integer from pointer without a cast [-Wint-conversion]
push("aa", "bb", "cc");
^
main.c:23:6: note: expected 'char' but argument is of type 'char *'
void push(char nm, char np, char tel) {
^
main.c:60:18: warning: passing argument 3 of 'push' makes integer from pointer without a cast [-Wint-conversion]
push("aa", "bb", "cc");
^
main.c:23:6: note: expected 'char' but argument is of type 'char *'
void push(char nm, char np, char tel) {
^
My question is : any solution ?