提问人:Nicholas 提问时间:4/7/2020 更新时间:4/7/2020 访问量:36
尝试从文本文件构建一个 2d 数组,但 endl char 被放置在输入上方,它是否在我的 for 循环中的位置错误?
Trying to build a 2d array from a text file but the endl char is being placed above the input, is it in the wrong place in my for loop?
问:
我正在尝试使用标准输入(在命令行中)从文本文件中打印出 20/20 数组。当我运行我的代码时,它被打印在一行中,迷宫字符上方有 19 行新行,而新行应该在每列的末尾?我做错了什么/代码中是否有我没有看到的错误?(MAZE_DIM = 20)
for(int rows = 0; rows < MAZE_DIM; rows++)
{
for(int columns = 0; columns < MAZE_DIM; columns++)
{
std::cin >> maze[rows][columns];
}
std::cout << std::endl;
}
这是用于在另一个函数中打印输入的代码
std::cout << “在下面打印迷宫:” << std::endl;
if(std::cin.good()){
std::cout << *maze << std::endl;}
这是输出,而每行的第 19 个字符之后应该有一行新行?
打印下面的迷宫: ====================S........===================.============......=.=============.=.=...============..=..=.=================.==.================....================.==.================.==.================.==.================.==.================.==.================.==.================.==.================.==.================.==.================.==.================.==.================E==============
答: 暂无答案
上一个:函数未显示数组参数的所需输出
评论
maze
std::cout << std::endl;
maze
'\n'