0

I was wondering if it is possible to create an array of enums like this:

typedef enum {
	LABEL,
	SCREEN_BUFFER,
	PID,
	ENABLED,
	NUM_BYTES
} SENSOR;

static SENSOR sensors[] = {
// formula // label //screen_buffer //pid //enabled // bytes
{ "Absolute Throttle Position:", "", "11", 1, 1 },
{ "Engine RPM:", "", "0C", 1, 2 },
{ "Vehicle Speed:", "", "0D", 1, 1 }
};

If this is not possible would someone give me some pointers on how to create something similar without have to build a class for each entry and storing it in a list or something like it. I'm trying to create a static array of a bunch of information about each sensor I can access on my vehicle through its OBD-II port.

4
Contributors
3
Replies
7
Views
8 Years
Discussion Span
Last Post by MrSpigot
0

I was wondering if it is possible to create an array of enums like this:

typedef enum {
	LABEL,
	SCREEN_BUFFER,
	PID,
	ENABLED,
	NUM_BYTES
} SENSOR;

static SENSOR sensors[] = {
// formula // label //screen_buffer //pid //enabled // bytes
{ "Absolute Throttle Position:", "", "11", 1, 1 },
{ "Engine RPM:", "", "0C", 1, 2 },
{ "Vehicle Speed:", "", "0D", 1, 1 }
};

As the previous poster said, you don't want to use an enum here.
You need something like:

struct
{
    char* LABEL;
    char* SCREEN_BUFFER;
    char* PID;
    int ENABLED;
    int NUM_BYTES;
} SENSOR;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.