user2467899 user2467899 - 1 year ago 89
C Question

Use a struct in a header file [ C - Linux ]

I tried to use an external struct but when I compile my c code I obtained this message:

subscripted value is neither array nor pointer nor vector



struct Request {
struct {
u_int data_len;
float *data_val;
} data;
bool_t last;
typedef struct Request Request;


#include "messaggio.h"

int main(void){
struct Request x;[0] = 4.6;
return 0;

Answer Source

The is a struct, so you cannot use [] with it. Maybe you want[0].

Try this code:

struct Request x; = 5; // initialize the length, use any value you need = (float *) malloc( * sizeof(float));[0] = 4.6
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download