double x=1.23
, what is *(&x)
?
What is NULL
? Hint: null pointer.
#include<stdio.h> void f(int i){i=0;} int main(){ int i=1; f(i); printf("i=%i\n",i); return 0; }
#include<stdio.h> void f(int* i){*i=0;} int main(){ int i=1; f(&i); printf("i=%i\n",i); return 0; }
#include<stdio.h> void f(int* i){i=NULL;} int main(){ int i=1; f(&i); printf("i=%i\n",i); return 0; }
void f(double a[])
–
what is actually passed to the function:
void f(double a[])
gets the array as parameter – can it figure out the size of the array?
int a[5];
and then try
a[7]=1;
what will happen? Hint: Segmentation
fault / causes.
#include<stdio.h> int i=2; /* file scope */ void f(){printf("i=%i\n",i);} int main(){ int i=1; /* function scope */ { int i=0; /* block scope */ printf("i=%i\n",i); } printf("i=%i\n",i); f(); return 0; }