I have completed an assignment, but Xcode is giving me a warning about the syntax of my for loop, and I'm not sure how to change it. I am new to programming. I am taking a course.
The assignment is to create two char arrays. One for month names, the other for total days in each month, then print both arrays combined sequentially (Jan 31 Feb 28 etc).
This is what I came up with:
f()
{
std::string months[] = { "January", "February", "March" };
std::string days[] = { "31", "28", "31" };
stringstream ss;
for (auto i = 0, j = 0; i < 3, j < 3; ++i, ++j)
{
ss << months[i] << " " << days[j] << " ";
}
}
The compiler doesn't like the middle part of the for statement, the test to stop. The message I get says "Expression result unused".
I confess I'm mostly mimicking the samples I've seen from class, but we've never done a loop that evaluates two arrays. I tried a range for loop, but I can't get that to work at all.
iandjnever diverge, why have two variables?i < 3, j < 3is not a valid expression.