J
jcf
I need to do the following: Our application builds information from a
string that is stored in a buffer that can be any of the following
formats: ABCD0102, ABCDEF0102, AB*CD*01*02, AB*CDEF*01*02. The only
information needed is the 4 digits at the end. The new format with
asterix seperation is an "upgrade" that I need to work around but also
be able to handle the older formats as well. Before, it would just go
by the position in the string to parse the "store" and "area" (the
information I need)
..
..
..
memcpy(store, buff+strlen(buff)-4,2);
memcpy(area, buff+strlen(buff)-2,2);
..
..
..
But, now I was thinking if I could just strip everything but the four
digits that are always there, before I do get to the memcopy's and
store that in a new buffer, it will still work fine. I was trying
sscanf, but can't get it to work.
/*strip(buff, new_buff)*/
memcpy(store, new_buff+strlen(new_buff)-4,2);
memcpy(area, new_buff+strlen(new_buff)-2,2);
string that is stored in a buffer that can be any of the following
formats: ABCD0102, ABCDEF0102, AB*CD*01*02, AB*CDEF*01*02. The only
information needed is the 4 digits at the end. The new format with
asterix seperation is an "upgrade" that I need to work around but also
be able to handle the older formats as well. Before, it would just go
by the position in the string to parse the "store" and "area" (the
information I need)
..
..
..
memcpy(store, buff+strlen(buff)-4,2);
memcpy(area, buff+strlen(buff)-2,2);
..
..
..
But, now I was thinking if I could just strip everything but the four
digits that are always there, before I do get to the memcopy's and
store that in a new buffer, it will still work fine. I was trying
sscanf, but can't get it to work.
/*strip(buff, new_buff)*/
memcpy(store, new_buff+strlen(new_buff)-4,2);
memcpy(area, new_buff+strlen(new_buff)-2,2);