3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Iam3R
1

is it possible to put void function into loop statement?

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

0

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"

1

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?

Edited by Aia: n/a

0

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.
...!!!!!!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.