typedef struct line {
int a;
int b;
} line;
int main() {
line *v;
int c, d, j;
char a;
int i;
scanf("%d", &n)
for (i = 0; i < n; i++) {
scanf("%c", &a);
v = (line*) malloc(n * sizeof(line));
if (a == '+') {
scanf("%d %d", &v[j]->a, &v[j]->b);
}
}
I want to make an array that holds a struct info, and then use that info in my function . But I am getting some errors and I don't know if I used well the pointer.
I have tried with v[j].a but it didn't work. (I used this because I am more familiar from linked-list.)
n. Suggest posting compilable code.scanf("%c", &a);-->scanf(" %c", &a);(Add space).scanf("%d", &n)This statement is missing the trailing;The posted code does not compile! amongst other things it is missing the#includestatement forstdio.h