c++;坐标网格地图标记坐标 ifstreammyfile; 打开(“config.txt”); if(myfile.fail()) { 你可能已经注意到C++本身没有设置一个字符在屏幕上的某个位置的功能。诅咒是一个相当广泛的库,它有助于这

c++;坐标网格地图标记坐标 ifstreammyfile; 打开(“config.txt”); if(myfile.fail()) { 你可能已经注意到C++本身没有设置一个字符在屏幕上的某个位置的功能。诅咒是一个相当广泛的库,它有助于这,c++,C++,c++;坐标网格地图标记坐标 ifstreammyfile; 打开(“config.txt”); if(myfile.fail()) { 你可能已经注意到C++本身没有设置一个字符在屏幕上的某个位置的功能。诅咒是一个相当广泛的库,它有助于这一点。但是,如果你想继续使用你自己的代码,你仍然可以从诅咒如何处理输出中得到一些灵感。Y,并且只有当您请求时,所有内容才会更新。您可以在自己的代码中执行类似操作。将要在屏幕上打印的内容存储在std::vectorI中。我会将网格存储在std::

c++;坐标网格地图标记坐标
ifstreammyfile;
打开(“config.txt”);
if(myfile.fail())
{

你可能已经注意到C++本身没有设置一个字符在屏幕上的某个位置的功能。诅咒是一个相当广泛的库,它有助于这一点。但是,如果你想继续使用你自己的代码,你仍然可以从诅咒如何处理输出中得到一些灵感。Y,并且只有当您请求时,所有内容才会更新。您可以在自己的代码中执行类似操作。将要在屏幕上打印的内容存储在
std::vectorI中。我会将网格存储在
std::vector
中并使用它。应用所有更改后,打印出来。收到了谢谢,将从那里开始,然后这里是示例代码。通常虽然你不会在这个网站上得到这样的代码,但是我有太多的时间:-你之前已经被告知了。这个问题可能有一个优雅的解决方案,但是没有人能用这个过于复杂的代码来测试它。嗯,谢谢代码,但是由于我在C++ 11上运行,我得到了一些错误,但是不知道如何修复。
ifstream myfile;
myfile.open("config.txt");

if (myfile.fail())
{
    cerr << "Error opening config file" << endl;
    myfile.close();
}

int line_no = 0;
while (line_no != 3 && getline(myfile, line3)) {
    ++line_no;
}


while (line_no != 7 && getline(myfile, line7)) {
    ++line_no;
}


while (line_no != 10 && getline(myfile, line10)) {
    ++line_no;
}


while (line_no != 14 && getline(myfile, line14)) {
    ++line_no;
}


while (line_no != 18 && getline(myfile, line18)) {
    ++line_no;
}
cout << line3 << endl;
cout << line7 << endl;
cout << line10 << endl;
cout << line14 << endl;
cout << line18 << endl;

gridXIdxA = stoi(ExtractString(line3, "=", "-"));
gridXIdxB = stoi(ExtractString(line3, "-", "\n"));
gridYIdxA = stoi(ExtractString(line7, "=", "-"));
gridYIdxB = stoi(ExtractString(line7, "-", "\n"));


cout << gridXIdxA << endl;
cout << gridXIdxB << endl;
cout << gridYIdxA << endl;
cout << gridYIdxB << endl;


int y = gridYIdxB + 1;
y > -1;
mapBoundaryX = gridXIdxB + 6;                                                           // dynamic array to print out boundary of city map
mapBoundaryY = gridYIdxB + 4;

int** dMapBoundaryArray;
dMapBoundaryArray = new int*[mapBoundaryX]();

for (int i = 0; i < mapBoundaryX; i++)
{
    dMapBoundaryArray[i] = new int[mapBoundaryY];
}


for (int i = 0; i < mapBoundaryX; i++)
{
    cout << endl;
    for (int j = 0; j < mapBoundaryY; j++)
    {
        dMapBoundaryArray[i][j] = i;
        if (i == 0 && j > 0 && j < gridXIdxB+4)
        {
            cout << "# "; // top
        }
        if (i == 0 && j == 0)
        {
            cout << " ";
        }

        if (i == (gridYIdxB+2) && j > 0 && j < gridXIdxB+4)
        {
            cout << "# "; // bottom
        }
        if (i == (gridYIdxB + 2) && j == 0)
        {
            cout << " ";
        }

        if (i>0 && i<12 && j==1)
        {
            cout << "#"; // left 
        }

        else if (i == 6 && j == 3)
        {
            cout << "  ";
            cout << 3;
        }

        else if (i == 6 && j == 4)
        {
            cout << " ";
            cout << 3;
        }

        else if (i == 7 && j == 4)
        {
            cout << " ";
            cout << 3;
        }

        else if (i > 0 && i < 12 && j == 13)   //right
        {
            cout << setw(24)<<right << "#";
        }

        if (i == 13 && j > -1 && j < 2)   //x axis 
        {
            cout << " ";
        }
        if (i == 13 && j > 1 && j < 13) 
        {
            x = x++; 
            cout <<" " << x;              //x axis 
        }

        if (j == 0 && i <= gridYIdxB+1  && i >= 1)  // y axis
        { 
            y = --y;
            cout << y;  //y axis
        }



    }
}
for (const auto& line : screen) {
    for (const auto& character : line) std::cout << character; 
    std::cout << "\n";
}