K&R doesn't go over it, but they use it. I tried seeing how it'd work by writing an example program, but it didn't go so well:
#include
int bleh (int *);
int main(){
char c = '5';
char *d = &c;
bleh((int *)d);
return 0;
}
int bleh(int *n){
printf("%d bleh\n", *n);
return *n;
}
It compiles, but my print statement spits out garbage variables (they're different every time I call the program). Any ideas?
No comments:
Post a Comment