 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Frank Mockenhaupt Guest
|
Posted: Thu Jan 26, 2006 1:44 pm Post subject: Array |
|
|
Hallo;
Wie kann ich alle Elemente eines Arrays direkt bei der Deklaration mit
einem (Start-)Wert definieren?
Vielen Dank
mfg
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Falk Tannhäuser Guest
|
Posted: Thu Jan 26, 2006 2:02 pm Post subject: Re: Array |
|
|
Frank Mockenhaupt wrote:
| Quote: | Wie kann ich alle Elemente eines Arrays direkt bei der Deklaration mit
einem (Start-)Wert definieren?
|
Meinst sicher "initialisieren".
int const arr[] = { 32, 16, 8 };
MfG
Falk
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Frank Mockenhaupt Guest
|
Posted: Thu Jan 26, 2006 3:37 pm Post subject: Re: Array |
|
|
Hallo;
Ich meine, wie ich alle Elemente eines Arrays beim Start mit einem Wert
initialisieren kann ohne explizit jeden Wert einzeln angeben zu müsse.
z.B. int array[] = {0,0,0,0}
MfG
Falk Tannhäuser schrieb:
| Quote: | Frank Mockenhaupt wrote:
Wie kann ich alle Elemente eines Arrays direkt bei der Deklaration mit
einem (Start-)Wert definieren?
Meinst sicher "initialisieren".
int const arr[] = { 32, 16, 8 };
MfG
Falk
|
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Dietmar Kuehl Guest
|
Posted: Fri Jan 27, 2006 1:16 am Post subject: Re: Array |
|
|
Frank Mockenhaupt wrote:
| Quote: | Ich meine, wie ich alle Elemente eines Arrays beim Start mit einem Wert
initialisieren kann ohne explizit jeden Wert einzeln angeben zu müsse.
z.B. int array[] = {0,0,0,0}
|
Für Arrays, die mit Null initialisiert werden sollen ist das einfach:
int array[10] = {};
Für den Fall, dass man einen anderen Wert haben möchte, muß man
allerdings die Notation etwas ändern:
std::vector<int> array(10, 17);
--
<mailto:dietmar_kuehl (AT) yahoo (DOT) com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|