J
jagmeena
Hello,
I am sure this problem has been addressed before, however, I could'nt get a
suitable solution to my problem. Hence I am posting here. Thanks a lot for
all your help.
The code I have is
typedef struct Rec {
unsigned char msg[10];
unsigned long len;
} rec;
static rec rc;
const unsigned char * tmp;
const char* getRec(const char* buf)
{
memset(&rc,0,sizeof(rc));
memcpy(rc.msg, buffer, strlen(buf);
rc.len = strlen(buf);
return (const char *)&rc;
}
long convertCharToLong(const unsigned char *lVal)
{
......
}
void main()
{
long v1;
char stg[100];
char buffer[255];
memset(buffer,0,255);
printf("Enter a string: ");
fgets(buffer);
tmp = getRec(buffer);
memset(stg,0,100);
memcpy(stg, tmp, 10);
printf("1. STG VALUE --> (%s)\n", stg);
v1 = convertCharToLong(tmp+10);
printf("2. LEN VALUE ---> (%ld)\n", v1);
}
The problem I have is writing the convertCharToLong function:
How do I convert the string I get from the offset, to a long value.
Thanks for all your help
jagmeena
(e-mail address removed)
I am sure this problem has been addressed before, however, I could'nt get a
suitable solution to my problem. Hence I am posting here. Thanks a lot for
all your help.
The code I have is
typedef struct Rec {
unsigned char msg[10];
unsigned long len;
} rec;
static rec rc;
const unsigned char * tmp;
const char* getRec(const char* buf)
{
memset(&rc,0,sizeof(rc));
memcpy(rc.msg, buffer, strlen(buf);
rc.len = strlen(buf);
return (const char *)&rc;
}
long convertCharToLong(const unsigned char *lVal)
{
......
}
void main()
{
long v1;
char stg[100];
char buffer[255];
memset(buffer,0,255);
printf("Enter a string: ");
fgets(buffer);
tmp = getRec(buffer);
memset(stg,0,100);
memcpy(stg, tmp, 10);
printf("1. STG VALUE --> (%s)\n", stg);
v1 = convertCharToLong(tmp+10);
printf("2. LEN VALUE ---> (%ld)\n", v1);
}
The problem I have is writing the convertCharToLong function:
How do I convert the string I get from the offset, to a long value.
Thanks for all your help
jagmeena
(e-mail address removed)