how the following two code parts same:
please don't double-space posted code. It just makes it harder to read.
#include <stdio.h>
void main ()
{
char i = NULL;
char &q = i;
^^^^
printf ( "%d", i);
printf ("%d", q);
}
The above is not C. It appears to be C++. Consulting your C++
textbook or the C++ FAQ for information about "references" should
answer your question. Failing that, try comp.lang.c++.
#include <stdio.h>
void main ()
Wrong. Make this "int main(void)" (or "int main()" if you mean to
write C++).
NULL is a null *pointer* constant. Assigning it to a char object
might happen to work, but it makes no sense. You probably mean
char i = '\0';
or
char i = 0;
(the two are equivalent).
char q = i;
^^
printf ( "%d", i);
printf ("%d", q);
}
You claim that the output is "0 0", but neither of your printf calls
prints a space character. If your program compiles and runs at all,
I'd expect the output to be "00". Either the code you posted isn't
your actual code, or the output you posted isn't your actual output.
You should copy-and-paste both your code and your output *exactly*;
don't try to re-type or paraphrase them.
You should print a new-line ("\n") at the end of your output. You
should also return a value from main(); add "return 0;" before the
closing brace. (This isn't strictly necessary in some circumstances,
but it's always a good idea.)
If you want the output to be understandable, consider something like:
printf("i = %d, q = %d\n", i, q);