gpt4 book ai didi

c++ - 来自 hflip 的段错误

转载 作者:行者123 更新时间:2023-11-28 07:07:32 25 4
gpt4 key购买 nike

出于某种原因,当我运行这段代码时出现段错误。它所做的是从输入中读取一个 PGM 文件并将其水平翻转。

这是我认为有问题的代码:

for (i = pixels.size()-1; i = 0; i--){ // this loop takes the final value of the original vector and puts it into the first spot in the new hflip vector, and continues onwards
flippy.push_back(pixels[i]);
}

cout << "P2" << endl << numColumns << " " << numRows << endl << "255" << endl;
while (p < pixTotal){
for (int z = 0; z < numRows; z++){
cout << flippy[p] << " ";
}
cout << endl;
p++;

}

最佳答案

你有

for (i = pixels.size()-1; i = 0; i--)

中间应该是

i>=0

不是

i=0

关于c++ - 来自 hflip 的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21566331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com