I created a simple code with the function void
where there is a passage by reference. However, it is giving the following error at compile time:
lala.c: In function 'main':
lala.c: 19: 12: warning: passing argument 2 of 'test' from incompatible pointer type [-Wincompatible-pointer-types]
test (i, & a);
^ lala.c: 4: 6: note: expected 'char **' but argument is of type 'char *'
void test (float i, char ** a)
^ ~~~~
Code:
#include <stdio.h>
#include <stdlib.h>
void teste (float i, char **a)
{
if (i<=7)
*a = "Menor ou igual a sete";
else
*a = "Maior que sete";
}
int main() {
float i;
char a;
printf("Digite o número ");
scanf("%f", &i);
teste (i, &a);
printf("%s\n", a);
system ("pause");
return 0;
}