-
passing arrays
I'm having some trouble figuring out how to pass arrays. I need to write a function with 3 parameters: a,b,i. A and B are char arrays. The parameter i is an int. The function inserts the string a into b immediately after index i. Assume b is large enough to hold the added characters.
So an example of what I'm trying to do is the following...
A is "Today Wednesday"
b is "is"
i is 6
and the result of the function would be
Today is Wednesday
So far I have this, the for loop finds the length of the string but I'm not sure how to write the function
#include <stdio.h>
#include <stdlib.h>
main()
{
int i;
char a[];
char b[];
for ( i = 0; a[i] != '\0'; i++ );
return i;
-
myfunction( char array1[], char array2[], int x )
{
}
call:
myfunction( arrayA, arrayB, varX );
On multiple dimension arrays, for a function definition, you can only omit the first [] size. All others must define the size of the array:
myfunction2( int array[][5][10] )
Called the same:
myfunction2( myMultiDimensionalArray );
Quzah.