0

I want to send an array to a function then print all of the elements. I have an error.

.LST file is:

BACI System: C-- to PCODE Compiler, 16:59 27 Oct 2005 Source file: 1.cm Fri Nov 01 03:16:20 2019 line pc 1 0
2 0
3 0
4 0 void Print(int a[]) Error near '[', line 4 of file 1.cm: ** syntax error Because of 1 error the PCODE file will not execute

Baci reference is: http://inside.mines.edu/~tcamp/baci/baci_index.html

C:\badosxe> bacc 1.cm Error near '[', line 4 of file 1.cm: ** syntax error>>Because of 1 error the PCODE file will not execute Pcode and tables are stored in 1.pco Compilation listing is stored in 1.lst

void Print(int a[])
{
        int i;
        for (i = 0; i < 5; i = i + 1)
        {
        cout<<a[i];
        }
}

main()
{
    cout << endl;
 cobegin
    {
    int a[5] = {1,2,3,4,5};

    Print(a);

    }
}
Hadi
  • 85
  • 1
  • 7
  • Don't post images unless necessary. Post the error as text. And please read [ask] – klutt Nov 01 '19 at 09:51
  • 1
    Please provide a URL to C--, and then please [edit] your question and post the error message as text. Yes, you can copy text from the command prompt! Just one observation: If C-- works similarly to C/C++ the indices count beginning with 0, not 1. The last element of a 5-element array is then indexed by 4. – the busybee Nov 01 '19 at 09:52

0 Answers0