From yechiel Mon Jun 2 01:24:34 2003 Subject: Re: thank you To: Date: Mon, 2 Jun 2003 01:24:34 +0300 (IDT) > Hello! > I was your student when studied matam a time ago. > Thank you for -ansi -Wall -pedantic. > Now (in structure of OS) this line saved me and my partners many days of > debugging. When we execute our program there were many mistakes and > strange things we couldn't find. After compiling with the Line we solved > all our problems. Without this flags gcc didn't get us message that we > forgot the word "case" inside "switch"! > BIG THANKS. I am truly happy for you, and I take it as a complement that you cared to tell me about it. Is it o.k. with you that I put your e-mail (without your names) on my Web-page, in order to encourage other students to do so? No hard feelings if you do not like the idea, and I won't do that unless I get an explicit consent from you. > One small question is left: when we initialize array like "int > arr[10]={0}" are all cells initialized or only the first one? > If you have time to answer->please do. The _basic_ rules for array initialization are as follows: Given the definition T-type arr[SIZE] = { val-0, val-1, /*** some more ***/, val-k}; First, in C, all val-i expressions must be constant-expressions. If SIZE < k+1 this is a syntax error (too many values). If there is an i 0 <= i <= k s.t. the type of val-i _cannot_ be converted to the type "T-type" it is a (semantical) compile-time error. Then, for every i 0 <= i <= k arr[i] is initialized as if there was a statement arr[i] = val-i; and for every i k < i < SIZE as if there was arr[i] = 0; In C++, the latter case the initialization is by the default Ctor. The rules are the same for structs (in C) where "T-type" may vary. The rules are the same for classes (in C++) where all non-static data-members are public (and a few more restrictions). The type "T-type" _can_ be a struct/class/array type by itself. I am sure you can draw the conclusion ;-> > Regards, > Enjoy Yechiel -------------------------------------------------------------------------------- Have you looked at recent updates to "Bad Books Amusement Park" ? Try http://www.cs.technion.ac.il/users/yechiel/CS/BadBooksC+C++.html Happy Jerusalem Day Yechiel M. Kimchi yechiel@someserver.someplace Faculty Comp. Sc. The Technion, Haifa, 32000 IL Office: (04) 829 4226 FAX: +(972) 4 82 9 3900 Homepage: http://www.cs.technion.ac.il/users/yechiel/