Visual Studio 2013 C compiling Syntax errors and C2100 illegal indirection error -


i've been trying write code university assignment, having lot of trouble compiling it. i'm begginer in c, , in programming in general, , have little experience finding errors. after looking @ code hours on end, have managed correct of them, there few quite persistent , can't pinpoint them. code bellow:

#include<stdio.h> #include<stdlib.h>  #define arraylength 20  typedef struct{ char *name; char *type; char *value; }variable;   int main(){     char calc[10];     char name1[20];     char name2[20];     int amount, i;     variable *varray;     int var1, var2;       printf("how many variables create? \n");     scanf("%d", amount);     varray = malloc(amount * arraylength * sizeof(variable));     (i = 0; < amount; i++){         if (varray[i].name == null || varray[i].type == null || varray[i].value == null){             printf("error: memory allocation failed. \n");             return 1;         }     } 

you can see declared variables not used in block of code. used in later pieces of program not seen here.

i have tried googling problem, , searching solution in older questions here, on stack overflow, nothing seems work specific errors, , such, decided ask own question.

any , appreciate it. please try simplify answers little bit, since, mentioned earlier, begginer.

you assigning "varray" value @ current addres, not address itself, cast has star in wrong place , unneeded:

varray = malloc(amount * arraylength * sizeof(variable)); 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -