arrays
- GeoKureli
-
GeoKureli
- Member since: Apr. 1, 2003
- Offline.
-
- Forum Stats
- Supporter
- Level 19
- Game Developer
im trying to learn arrays, and i guess they're really different than what im used to. i keep getting the error "too many initializers". heres my code
#include <iostream>
#include<string>
using namespace std;
int coinValue[] = {100, 25, 10, 5, 1};
char coinName[] = {"dollar", "quarter", "dime", "nickel", "penny"};
both array lines are wrong and both are getting errors. what am i doing wrong? os there a tutorial for array, anyone? i skimmed c++: main and didnt find one
This blog I made | This game sucks | FlxGreed | Home Run Swingers: Rhythm Baseball
many typos
- Xivectro
-
Xivectro
- Member since: Oct. 5, 2006
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
I am no programming guru and have never, seriously, checked out C++ till just now.
So i was bored and decided to "try" to help you, and heres what "might" the problem.
"both array lines are wrong and both are getting errors. what am i doing wrong?"
error "too many initializers":
The compiler encountered more initializers than were allowed by the declaration being initialized.
Array Syntax:
type name [elements];
i honestly have no clue, but i'm guessing you should assign a value in your brackets equal to the number of items in your array??
Or it could be something completely different.
Consider what your doing, how you're doing it, & the code you're using; maybe this guide will help?
C++ Arrays: Tutorial
- Jordan
-
Jordan
- Member since: Apr. 23, 2006
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
- elbekko
-
elbekko
- Member since: Jul. 23, 2004
- Offline.
-
- Forum Stats
- Member
- Level 16
- Blank Slate
I have a feeling that
char coinName[] = {"dollar", "quarter", "dime", "nickel", "penny"};
is going to throw even more errors. You'll need a string array, not a char array.
char array = string =)
string coinName[5] = {"dollar", "quarter", "dime", "nickel", "penny"};
should be correct I think.
"My software never has bugs. It just develops random features. " - Unknown
[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]
- GeoKureli
-
GeoKureli
- Member since: Apr. 1, 2003
- Offline.
-
- Forum Stats
- Supporter
- Level 19
- Game Developer
This blog I made | This game sucks | FlxGreed | Home Run Swingers: Rhythm Baseball
many typos

