How to explain precisely "static double sum;"? Does it reserve memory?
How to explain precisely "static double sum;"? Does it reserve memory?
This will reserve sizeof(double) bytes and as it is declared as static it wont be destroyed when it goes out of scope and will instead hold its value until it is referenced again.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Yes.
Though the static keyword has 2 meanings, depending on where the variable was declared.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
So I think if i define a structure.
struct consumer{
char *name[30];
char *address[60];
....
} z;
should it reserve memory?
i think it is right.
Am I right?
does that mean I could use "size of" to judge whether it reserve memory?
> Am I right?
Yes
> does that mean I could use "size of" to judge whether it reserve memory?
No
You can also use sizeof on a type
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.