J
jimjim
#include <stdio.h>
#include <stdlib.h>
//WARNING: The function's signature should be: f( int ** )
void f(int *ip) {
static int dummy = 5;
*ip = &dummy;
}
int main(){
int *ip;
f(&ip);
printf("%d",*ip);
return 0;
}
The function's signature should be: f( int ** ). However, f( int *) seems to
produce the same results, even though I am
warned by the compiler (Borland_bcc_5.5):
Warning W8069 solution.c 5: Nonportable pointer conversion in function f
Warning W8075 solution.c 12: Suspicious pointer conversion in function main
What can go wrong when you pass the address of a pointer to a function that
does not recieve a pointer to a pointer?
TIA
jimjim
#include <stdlib.h>
//WARNING: The function's signature should be: f( int ** )
void f(int *ip) {
static int dummy = 5;
*ip = &dummy;
}
int main(){
int *ip;
f(&ip);
printf("%d",*ip);
return 0;
}
The function's signature should be: f( int ** ). However, f( int *) seems to
produce the same results, even though I am
warned by the compiler (Borland_bcc_5.5):
Warning W8069 solution.c 5: Nonportable pointer conversion in function f
Warning W8075 solution.c 12: Suspicious pointer conversion in function main
What can go wrong when you pass the address of a pointer to a function that
does not recieve a pointer to a pointer?
TIA
jimjim