help with functions?

hello im writing this program
and it's a little bit tiresome

so my question is it possible to make this for loop part a function?
so i can just call it everytime i need it?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

void z() 
{
	delay(25);
}



int main()

{
	///some codes here
	{
		char x[]="Show this text slowly";
		for (int i=0;i<sizeof(x);i++)    ///i want this part to be a function
		{
		cout<< x [i];                  ///up until here
		z();
		}
	}


so is it possible?or is there any other way to do something just like that?
i have like 100+ lines to write :'(
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void printChar(char arr[], int temp)
{
    for (int i=0;i<temp;i++)
    {
        cout<< arr[i];
    }
}

int main()

{

    char x[]="Show this text slowly";
    printChar(x,sizeof(x));
}


You can pass the array and its size to a function and let it print out that array.

I don't see how that makes any difference to a number of lines you are supposed to write though.
thanks it works :D
Topic archived. No new replies allowed.