Can I have an array as an argument for a void function?

I'm working with 17-segment (or in this case 16-segment because I'm taking out the decimal point to make things easier) alphanumeric LED displays, and want to have my code so that I can just change an array in calling the displayString function and it will interpret it and display it on the LEDs.

This is the code that defines the function:

void displayString(int string[]){
  //there are some functions in here for the 74HC595 shift
  //registers that are driving the segments as well
  for(int i = 0; i < sizeof(string); i++){
      case 'A':
        //I previously defined lists named A-Z with the pins of the
        //display that should be lit for the according character
        for(int x; x < sizeof(A); x++){
          setRegisterPin(A[x] + (i * 16), HIGH);
      case 'B':
        for(int x; x < sizeof(B); x++){
          setRegisterPin(B[x] + (i * 16), HIGH);

And here is the part where I call the function:

void loop(){
  displayString ({'A', 'B'});

And when I verify the program, I get the following
error: expected primary-expression before '{' token

I've tried some different syntax for calling it, none of which worked, but that could easily be where the problem lies and it's the only thing I can think of that would be causing this error. So, ultimately... does anyone know the syntax for doing this?

Nope, you cannot pass arrays like that in C. You will have to create a variable. Now if it was defined to accept a char array, you could pass it "AB".

Your "string" would normally consist of chars, not ints. I suggest that you find a basic book or ebook for C syntax and read it, rather than randomly blundering around.

Now if it was defined to accept a char array, you could pass it "AB".

This would actually be preffered over creating a list of charcters for every string, but how would I do that? Despite a bit of research I've done on the topic, I'm still kind of confused as to how C handles strings, chars, char arrays, etc. and how to use them.

Wait... actually I just noticed that in the void initializer I told it that the list would consist of integers, not chars. A-derpty-derp :stuck_out_tongue: I changed that and then replaced the ({"A", "B",}) with ("AB") and now it is working fine. Thanks!

I just noticed that in the void initializer ...

Just to get the terminology right, it is a function initializer.

"void" is the return value (ie. nothing returned).

You call a function. You pass parameters (arguments). The function may or may not return a value. If not, it is declared "void".


Function taking no arguments and returning nothing:

void foo (void) ...

Function taking no arguments and returning an int:

int foo (void) ...

Function taking an int argument and returning an int:

int foo (int bar) ...

Ahhh. Thanks, that makes much more sense!