When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
28 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
the output i get is
{
"topLeft" : [5,10],
"bottomRight" : [5,10],
}
it should be
the output should be
{
"topLeft" : [5,5],
"bottomRight" : [5,5],
}
what does your input file look like?
you should use a debugger, so you can step through line by line allowing you see see what the program is doing
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 *
this is the input im using currently
but yeah i have been debugging and column isnt resetting, at the end of a row it should go back to 0
it apprers to be resetting to 0:
i changed the if statement to look like this to show it:
// check if the current character is a new line
if (current == '\n') {
if (topLeftRow != -1) {
result = result + "topLeft : [" + to_string(topLeftRow) + "," +
to_string(topLeftCol) + "],\n";
result = result + "bottomRight : [" + to_string(bottomRightRow) +
"," + to_string(bottomRightCol) + "],\n";
}
row++;
std::cout << "i have been reset to 0." << std::endl;
column = 0;
// reset the coordinates
topLeftRow = topLeftCol = bottomRightRow = bottomRightCol = -1;
}
just added std::cout << "i have been reset to 0." << std::endl; before the column = 0
another thing i just realise is that i was forgetting to ignore whitespace
which is so simple
yes, the debugger showed that here:
current = 32, which is newline
yeah i cant believe i forgot about that
its standard practice to overlook the most common things during programming, i happens to us all
yeah i still think the logic is slightly off though
i tried a different txt and get
{
"topLeft" : [2,15],
"bottomRight" : [2,15],
"topLeft" : [3,15],
"bottomRight" : [3,15],
"topLeft" : [4,15],
"bottomRight" : [4,15],
}
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
if your still worried about newlines, you can use std::getline which will give you a string from the stream terminated by a newline.
i dont want the 4 middle ones only the topLeft and bottomRight
i dont think that was the issue all along since the columns seem to be correct now
what is the point of the astrixes?
and what are you trying to represent with this file format (pixels)?
did you design it?
this doesnt solve anything, you already know what you need to change now, i just want to know cos im curious
reading the comments, it seems to imply that 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * is a top left coordernate
i think the point is to take a txt then mark the coordinates of the rectangle, no its just work i was doing but plateaued for ages
cause the * would be top left and bottom right assuming its a rectangle or square and its 1 by 1
the comments arent that accurate atm becasue ive been trying a bunch of diff things and moving stuff around
but thank you for the guidance
<@undefined>
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.