Functions

closed account (LN7oGNh0)
I was wondering if it is possible to call functions from a loop. (more specifically a 'for' loop.
Yes. It's nothing special about calling a function from a for loop. You do it the same way as always.
Last edited on
Yes, there is a few ways you can do it.
1
2
3
4
5
6
7
for (int i = 0; i < 10; i ++)
   CountDown(i); // CountDown get's called 10 times

// Or...

for (unsigned int i = 0; i < myString.size(); i ++) // myString.size() is called n + 1 times
   myString[i] = toupper(myString[i]); // Is called n times where n = myString.size() 
Last edited on
closed account (LN7oGNh0)
OK. so how do you do it?
Check it out dude

1
2
3
4
5
// This loop gives words to fillfreqency function from inputarray
	for( string::size_type i = 0; i < size; i++)
	{
		fillFrequency(inputarray[i], freqcount, alphabet);
	}
closed account (LN7oGNh0)
Alright, thanks!
Topic archived. No new replies allowed.