|
|
|
AnsiString и unsigned char*
|
|||
|---|---|---|---|
|
#18+
Карабас Барабас AkhДык это уже не С?как это не С ? я другими языками не владею :) Я не встречал такого в учебниках :( ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.09.2006, 16:08 |
|
||
|
AnsiString и unsigned char*
|
|||
|---|---|---|---|
|
#18+
AkhЯ не встречал такого в учебниках :( полез в стандарт: ANSI/ISO C++ Professional Programmer's HandbookInitializing Local Automatic Structs and Arrays One way to initialize automatic POD objects is by calling memset() or a similar initialization function. However, there is a much simpler way to do it -- without calling a function, as you can see in the following example: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. This technique is applicable to every POD struct. It relies on the fact that the first member is a fundamental data type. The initializer zero is automatically cast to the appropriate fundamental type. It is guaranteed that whenever the initialization list contains fewer initializers than the number of members, the rest of the members are initialized to binary zeros as well. Note that even if the definition of Person changes -- additional members are added to it or the members' ordering is swapped -- all its members are still initialized. The same initialization technique is also applicable to local automatic arrays of fundamental types as well as to arrays of POD objects : [src c++]void f() { char name[100] = {0}; //all array elements are initialized to '\0' float farr[100] = {0}; //all array elements are initialized to 0.0 int iarr[100] = {0}; //all array elements are initialized to 0 void *pvarr[100] = {0};//array of void * all elements are initialized to NULL //...use the arrays }[src] Posted via ActualForum NNTP Server 1.3 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.09.2006, 16:19 |
|
||
|
AnsiString и unsigned char*
|
|||
|---|---|---|---|
|
#18+
Карабас Барабас Супер! Я даже и не мечтал. :) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.09.2006, 16:21 |
|
||
|
AnsiString и unsigned char*
|
|||
|---|---|---|---|
|
#18+
вернее вот так: ANSI/ISO C++ Professional Programmer's HandbookInitializing Local Automatic Structs and Arrays One way to initialize automatic POD objects is by calling memset() or a similar initialization function. However, there is a much simpler way to do it -- without calling a function, as you can see in the following example: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. This technique is applicable to every POD struct. It relies on the fact that the first member is a fundamental data type. The initializer zero is automatically cast to the appropriate fundamental type. It is guaranteed that whenever the initialization list contains fewer initializers than the number of members, the rest of the members are initialized to binary zeros as well. Note that even if the definition of Person changes -- additional members are added to it or the members' ordering is swapped -- all its members are still initialized. The same initialization technique is also applicable to local automatic arrays of fundamental types as well as to arrays of POD objects : Код: plaintext 1. 2. 3. 4. 5. 6. 7. Posted via ActualForum NNTP Server 1.3 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.09.2006, 16:21 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=33987947&tid=2030507]: |
0ms |
get settings: |
5ms |
get forum list: |
17ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
71ms |
get topic data: |
8ms |
get forum data: |
3ms |
get page messages: |
34ms |
get tp. blocked users: |
1ms |
| others: | 245ms |
| total: | 390ms |

| 0 / 0 |
