So my problem is kinda annoying. I have to create a struc called vector, which holds a string ~ array of chars. For later use. What Ive written so far:
vector.h
// forward declare structs and bring them from the tag namespace to the ordi$
typedef struct Vector Vector;
// actually define the structs
struct Vector {
int SortPlace;
char LineContent[100];
};
vector.c
// Initialize a vector to be empty.
// Pre: v != NULL
void Vector_ctor(Vector *v) {
assert(v); // In case of no vector v
(*v).SortPlace = 0;
(*v).LineContent[100] = {""};
}
My error message is:
vector.c: In function ‘Vector_ctor’:
vector.c:13:24: error: expected expression before ‘{’ token
v->LineContent[100] = {""};
Since im new to c programming im kinda lost. Basically i want to create a vector with no content.
Any help would be appreciated. Greetings
(*v).foo~>v->foo((*v).foois not wrong, but it's awkward to read)vector.c:#include "vector.h"vector.henclose your code in#ifndef VECTOR_H_INCLUDEDnewline#define VECTOR_H_INCLUDEDand#endif. See Why include guards?(*v).LineContent[100] = {""};===>(*v).LineContent[0] = 0;