Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error in running a simple C code in visual studio [closed]

I wrote a simple C code for displaying a matrix in visual studio but it gives the following errors:

-Error 1 error C2085: 'main' : not in formal parameter list

-Error 2 error C2143: syntax error : missing ';' before '{'

-Error 3 error C2084: function 'void print_matrix(float (*)[3])'

as I'm new in C language I don't know where is the problem and how to cope with it. Thanks for any help

here is the written code:

#include <stdio.h>

void print_matrix (float a [3][3])

void main(void)
{
    float p [3][3] = { {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0} };
printf("\nMatrix 1:\n");
print_matrix(p);
}

void print_matrix(float a [3][3])
{
    int ii,jj;
        for (ii=0;ii<3;ii++){
            for (jj=0;jj<3;jj++){
                printf("%f\t",a[ii][jj]);
    }
            printf("\n");
    }
}
like image 763
maryam yousefi Avatar asked Feb 03 '26 12:02

maryam yousefi


1 Answers

You forgot a semicolon ; after your function declaration. Moreover the prototype of main is int main(void) or int main(int, char **), not void main(void).

like image 101
md5 Avatar answered Feb 05 '26 01:02

md5



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!