strings 1-9 not printed ; array

I created a string array with 30 strings. But the strings 1-9 wont get printed, when I try to print them out using a for loop.
Can't help without seeing any code.
I declared them like this:
int x
1
2
3
4
5
6
7
8
int x=0;
string array [30];

array [x] = water; x++;
array [x] = fire;x++;
...
 
for (int a = 0; a<x ;a++) cout << array [a] << endl;
Assuming I want to print the contents of the array with 10 strings, I would:

1
2
3
4
5
6
7
int i;
string arr[10]={"AAA","BBB","CCC","DDD","EEE","FFF","GGG","HHH","III","JJJ"};

for(i=0;i<10;i++)
{
	cout<<arr[i]<<endl;
}
The OP's printing out is OK , however more readable if in the same format as iantac's code.

The initialisation looks dodgey though, should also be in a for loop.

Perhaps all the code for this part rather than an abbreviated part.

Edit:

Depends on the value of a.
Last edited on
Thats not possible. There is a very specific reason, why I have to declare the words like a showed you in the example. So I still need some help guys!
¿Are water and fire variables?
OK, I just tried a very easy programm that looks like the example I gave you all. And it worked just fine. But the actual program I`m talking about does not work the same way. I am going to show you the actual code tomorrow. Maybe I made a mistake somewhere that the compiler doesnt recognise as an error.

The actual program is on another PC, so I`ll post the code tomorrow, please help me then!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
void MyVars () {
    string frenchWords [30];
    string translation[30];
    int x = 0;

char specialStrings [] = {"abrevenir      "}; specialStrings [3] = 130;
frenchWords [x] = specialStrings;
translation [x] = "Abkuerzung"; x++;

frenchWords [x] = "accommoder";
translation [x] = "schlichten"; x++;

frenchWords [x] = "s`accroupir";
translation [x] = "niederhocken"; x++;

frenchWords [x] = "achever ";
translation [x] = "vollenden"; x++;

strcpy(specialStrings, "acquerir"); specialStrings [4] = 130;
frenchWords [x] = specialStrings;
translation [x] = "erwerben"; x++;

frenchWords [x] = "acquiescer";
translation [x] = "einwilligen"; x++;

frenchWords [x] = "un adepte";
translation [x] = "Anfaenger"; x++;

strcpy(specialStrings, "adhesif "); specialStrings [3] = 130;
frenchWords [x] = specialStrings;
translation [x] = "anklebend"; x++;

frenchWords [x] = "une allusion";
translation [x] = "Anspielung"; x++;

strcpy(specialStrings, "un aprecu"); specialStrings [7] = 135;
frenchWords [x] = specialStrings;
translation [x] = "Uebersicht"; x++;

strcpy(specialStrings, "apprehension"); specialStrings [4] = 130;
frenchWords [x] = specialStrings;
translation [x] = "Besorgnis"; x++;

frenchWords [x] = "assommant";
translation [x] = "todlangweilig"; x++;

frenchWords [x] = "assoupir";
translation [x] = "betaeuben"; x++;

frenchWords [x] = "avertir ";
translation [x] = "benachrichten"; x++;

frenchWords [x] = "balayer ";
translation [x] = "kehren"; x++;

frenchWords [x] = "balustrade";
translation [x] = "Gelaender"; x++;

frenchWords [x] = "biais   ";
translation [x] = "schraeg"; x++;

frenchWords [x] = "bidon   ";
translation [x] = "Kanister"; x++;

strcpy(specialStrings, "blemir  "); specialStrings [2] = 136;
frenchWords [x] = specialStrings;
translation [x] = "erblassen"; x++;

frenchWords [x] = "bougonner";
translation [x] = "noergeln"; x++;

frenchWords [x] = "carnet    ";
translation [x] = "Notizbuch"; x++;

frenchWords [x] = "cendre   ";
translation [x] = "Asche"; x++;

frenchWords [x] = "cerner    ";
translation [x] = "umzingeln"; x++;

frenchWords [x] = "chagrin  ";
translation [x] = "Kummer"; x++;

frenchWords [x] = "cicatrice";
translation [x] = "Narbe"; x++;

frenchWords [x] = "compenser";
translation [x] = "ausgleichen"; x++;

strcpy(specialStrings, "conge   "); specialStrings [4] = 130;
frenchWords [x] = specialStrings;
translation [x] = "erblassen"; x++;

for (int a = 0; a < x; a++) {
          cout << frenchWords [a]; 
          cout << "\t\t";
          cout << translation [a] << endl;


That is the code. A little long, but any other code, works, but this one, so please take a look, guys!
*Note: }} at the end

Wait!!!!!!!! Now suddenly it works!!!!! Using another computer. But how can the computer play a role???
Likely the error isn't at that part of the code. You may have an [out of bound] error somewhere else in your code. It's not predictable how such an error manifests.
Topic archived. No new replies allowed.