enum stuff get lost

A

ajay

Hi All,
I get lost in enum stuff.
can anyone help me out from this puzzle.
i'm not able to get the values which i set.
see the following piece of code.


/** typedef.h ****/

/***** I have an enum ******/

enum RequestParameter{
request_IMSI = 0,
request_AuthenticationSet = 1,
request_SubscriberData = 2,
request_CUG_Information = 3,
request_Ki = 4
};

/*** now i have to create an arry of above enum of size 2 ******/
typedef RequestParameter RequestParameters[2];


/**** getSet.c ******/

/*** I wrote method to get and set this enum array ***/
RequestParameters reqParams;

void setReqParams(RequestParameters* in)
{
reqParams = in;
}

bool getReqParams(RequestParameters* out)
{
out = reqParams;
}

/**** main.c *****/
/***** now i use get set methods *****/

/*** here i set the value ***/

RequestParameters reqParams;
reqParams[0] = request_IMSI;
setReqParams(&reqParams);


/**** here i get the value ******/
RequestParameters reqParams;
getReqParams(&reqParams));

printf("reqParam = %d" , reqParam[0] );
/** i'm not able to get the values which i set printed value is garbage ***/

if ( reqParams[0] == request_IMSI )
{
......
}
else if ( reqParams[0] == request_AuthenticationSet )
{
.....
}

......
...
 
E

Emmanuel Delahaye

In said:
Hi All,
I get lost in enum stuff.
can anyone help me out from this puzzle.
i'm not able to get the values which i set.
see the following piece of code.


/** typedef.h ****/

/***** I have an enum ******/

enum RequestParameter{
request_IMSI = 0,
request_AuthenticationSet = 1,
request_SubscriberData = 2,
request_CUG_Information = 3,
request_Ki = 4
};

/*** now i have to create an arry of above enum of size 2 ******/
typedef RequestParameter RequestParameters[2];

Should be

typedef enum RequestParameter RequestParameters[2];

but typedefing arrays is rarely useful.
/**** getSet.c ******/

/*** I wrote method to get and set this enum array ***/
RequestParameters reqParams;

void setReqParams(RequestParameters* in)

'RequestParameters' is an array type that decays in a pointer type because it
is a parameter. Are you sure you want a pointer to a pointer here?
{
reqParams = in;

What is reqParams ?
}

bool getReqParams(RequestParameters* out)
{
out = reqParams;

out = reqParams;

What is reqParams ?
Modifying a parameter is often the sign of a design error. Do you really want
to do that?
}

/**** main.c *****/
/***** now i use get set methods *****/

/*** here i set the value ***/

RequestParameters reqParams;
reqParams[0] = request_IMSI;

You can't do that outside a function.
setReqParams(&reqParams);

It's hard to understand the purpose of this function.
/**** here i get the value ******/
RequestParameters reqParams;
getReqParams(&reqParams));

It's hard to understand the purpose of this function.
printf("reqParam = %d" , reqParam[0] );
/** i'm not able to get the values which i set printed value is garbage
***/

if ( reqParams[0] == request_IMSI )
{
.....
}
else if ( reqParams[0] == request_AuthenticationSet )
{
....
}

You seem completely confused. I think you should try to explain what you want
to do exactly, and we will try to help you to implement it if it makes sense.
 
A

ajay

Tx ED for ur time.I solved it anyhow.

Emmanuel Delahaye said:
In said:
Hi All,
I get lost in enum stuff.
can anyone help me out from this puzzle.
i'm not able to get the values which i set.
see the following piece of code.


/** typedef.h ****/

/***** I have an enum ******/

enum RequestParameter{
request_IMSI = 0,
request_AuthenticationSet = 1,
request_SubscriberData = 2,
request_CUG_Information = 3,
request_Ki = 4
};

/*** now i have to create an arry of above enum of size 2 ******/
typedef RequestParameter RequestParameters[2];

Should be

typedef enum RequestParameter RequestParameters[2];

but typedefing arrays is rarely useful.
/**** getSet.c ******/

/*** I wrote method to get and set this enum array ***/
RequestParameters reqParams;

void setReqParams(RequestParameters* in)

'RequestParameters' is an array type that decays in a pointer type because it
is a parameter. Are you sure you want a pointer to a pointer here?
{
reqParams = in;

What is reqParams ?
}

bool getReqParams(RequestParameters* out)
{
out = reqParams;

out = reqParams;

What is reqParams ?
Modifying a parameter is often the sign of a design error. Do you really want
to do that?
}

/**** main.c *****/
/***** now i use get set methods *****/

/*** here i set the value ***/

RequestParameters reqParams;
reqParams[0] = request_IMSI;

You can't do that outside a function.
setReqParams(&reqParams);

It's hard to understand the purpose of this function.
/**** here i get the value ******/
RequestParameters reqParams;
getReqParams(&reqParams));

It's hard to understand the purpose of this function.
printf("reqParam = %d" , reqParam[0] );
/** i'm not able to get the values which i set printed value is garbage
***/

if ( reqParams[0] == request_IMSI )
{
.....
}
else if ( reqParams[0] == request_AuthenticationSet )
{
....
}

You seem completely confused. I think you should try to explain what you want
to do exactly, and we will try to help you to implement it if it makes sense.
 
P

Peter Shaggy Haywood

Groovy hepcat Emmanuel Delahaye was jivin' on 24 Jun 2003 15:13:05 GMT
in comp.lang.c.
Re: enum stuff get lost's a cool scene! Dig it!
In said:
Hi All,
I get lost in enum stuff.
can anyone help me out from this puzzle.
i'm not able to get the values which i set.
see the following piece of code.


/** typedef.h ****/

/***** I have an enum ******/

enum RequestParameter{
request_IMSI = 0,
request_AuthenticationSet = 1,
request_SubscriberData = 2,
request_CUG_Information = 3,
request_Ki = 4
};

/*** now i have to create an arry of above enum of size 2 ******/
typedef RequestParameter RequestParameters[2];

Should be

typedef enum RequestParameter RequestParameters[2];

but typedefing arrays is rarely useful.
/**** getSet.c ******/

/*** I wrote method to get and set this enum array ***/
RequestParameters reqParams;
^^^^^^^^^
This is reqParams.
^
'RequestParameters' is an array type that decays in a pointer type because it
is a parameter. Are you sure you want a pointer to a pointer here?

RequestParams is not a parameter. RequestParams is, as you have
correctly said, an array type. But the parameter, named in, is a
pointer to this array type.
What is reqParams ?

See above.
What is reqParams ?

See above.
Modifying a parameter is often the sign of a design error. Do you really want
to do that?

I believe he's trying to modify what the parameter points at. Of
course, he can't do that, since it is an array.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top