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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.