Re: How to pass an array to founction
James Hamilton <[email protected]>
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <CA+GRqLY-BQvCWdB2TDGbRSyVrmZ6CrpEFdnKb_erbT_0GuNjvA@mail.gmail.com> |
Something like this:
void compute(char *a, int aLen) { // could also be "unsigned int aLen"
if (a == NULL || aLen < 1) {
// error
return;
}
a[0] = 'A';
// make sure to check the length of the array before referencing deeper
into it
...
...
}
char arr[20];
compute(arr, 20);
...
Good luck!
~James
_______________________________________________
AVR-GCC-list mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list