今天是我第一次在一段時間內使用C++。我通常是一個Python程序員。 我不斷收到段錯誤,並將其隔離到註釋行。 (註釋去掉,當被註釋掉事業段錯誤的那些)我有段錯誤!
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include "defaultfile.h"
int main()
{
ifstream mapin;
string map;
string s;
int i = 0;
while (i<=22){i++;top[i][0]="__";i++;};i=0;
while (i<=21){i++;frw[i][0]="/";i++;};i=0;
while (i<=21){i++;bck[i][0]="\\";i++;};i=0;
//while (i<=45){i++;spc[i][0]=" ";i++;};i=0;
//while (i<=112){i++;spc[i][1]="n";i++;};i=0;
while (i<=22){i++;cout<<top[i][1]<<endl;i++;};i=0;
while (i<=21){i++;cout<<frw[i][1]<<endl;i++;};i=0;
while (i<=21){i++;cout<<bck[i][1]<<endl;i++;};i=0;
//while (i<=45){i++;cout<<spc[i][1]<<endl;i++;};i=0;
...
}
標題是:
string top[23][3] =
{{"", "", ""},
...
{"", "", ""}};
string frw[22][3] =
{{"", "", ""},
...
{"", "", ""}};
string bck[22][3] =
{{"", "", ""},
...
{"", "", ""}};
string spc[46][3] =
{{"", "", ""},
...
{"", "", ""}};
編輯: 謝謝。我總是想念和花費一個小時試圖尋找的愚蠢的東西。我需要的只是別人來指出。
標題接縫凌亂 – Daniel 2011-03-20 06:02:16
你爲什麼要初始化那樣的字符串? – quasiverse 2011-03-20 06:02:38
題外話題:空格和換行符是你的朋友! – 2011-03-20 06:03:02