Answer the question
In order to leave comments, you need to log in
How to remove a statement after one iteration of a loop in C++?
For example, there is a loop:
for (; ;) {
if (condition) {
//do_something
}
// remaining body
}
If at the beginning I only need one check on the first iteration - can I remove it after it goes through?
Answer the question
In order to leave comments, you need to log in
Delete is not possible. You can write a check "whether this is the first iteration".
#include <iostream>
int main (int argc, char ** argv)
{
int i =1;
for ( (std::cout << "Hello word",i =0) ; i < 10 ; i++)
{
std::cout << i<<std::endl;
}
return 0;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question