我想我有一個數組索引問題,下面的代碼它編譯o.k.在奧威爾開發CPP,但是當我運行它時,我得到了上下箭頭輸出,我認爲這表明某種問題與條件語句之一。我期待所有的數字輸出。數組索引問題
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std ;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
char name[2] ;
cout << "Type aa ab ba or bb" << endl ;
fgets(name , 2, stdin) ;
cout << "The first letter of the name is " << name[0] << endl ;
cout << "The second letter of the name is " << name[1] << endl ;
int name_length ;
name_length = strlen(name) -1 ;
cout << "The length of the name is " << name_length << endl;
char Kaballah_Chaldean_Main[2][2] ;
/* Set the Main Chaldean Kaballah */
Kaballah_Chaldean_Main[1][1] = 'A' ;
Kaballah_Chaldean_Main[2][1] = 'B' ;
Kaballah_Chaldean_Main[1][2] = 1 ;
Kaballah_Chaldean_Main[2][2] = 2 ;
unsigned int x = 0 ;
unsigned int Chaldean_Letter_Index ;
cout << "Name_Lenght is " << name_length << "Chaldean_Letter_Index "<< Chaldean_Letter_Index << "x " << x << endl ;
for (x = 0 ; name_length >= x; x = x + 1) {
cout << "x " << x << "Name Length is " << name_length << endl ;
for (Chaldean_Letter_Index = 1; Chaldean_Letter_Index <= 2 ; Chaldean_Letter_Index = Chaldean_Letter_Index+ 1) {
cout << "Chaldean Letter Index" << Chaldean_Letter_Index << endl ;
cout << "x " << x <<"Name letter " << name[x] << endl ;
}
}
return 0;
}