is it possible to put void function into loop statement?

Recommended Answers

All 4 Replies

is it possible to put void function into loop statement?

Yes, why do you ask? There must be something else you want to know.

yeah, the whole matter is that i want to call void function in while loop as following:

while(search(arg1, arg2, &arg3)){
...
}

(search is void function)

and when i execute the program, im getting following mistake:
"controlling expressions must have scalar type"

I knew there was more to it than what you stated previously.
What you wanted to know is if a void function can be use as the stop control for a loop. And the answer is ... no. There's nothing for the while loop to evaluate.

When do you want the loop to stop?

yeah, the whole matter is that i want to call void function in while loop as following:

while(search(arg1, arg2, &arg3)){
...
}

(search is void function)

and when i execute the program, im getting following mistake:
"controlling expressions must have scalar type"

while(search(arg1, arg2, &arg3)){
...
}

this you cannot do..! to do that your function should return a value
a void function can be used in the loop in the foll: way

while(somecond)
{
search(arg1, arg2, &arg3);
...
}

unless your function returns a value you cannot use that as a condition in loops as you did.
...!!!!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.