Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to retrieve only last specify length of byte

Status
Not open for further replies.

vintl

Technical User
Jun 9, 2000
72
0
0
MY
I have this string info[35]. i want to extract the last 7 byte, so i shall extract from &info[29]. I use memmove to do this extracting, but return funny characters.

memset(nfo, 0x00, sizeof(nfo));
memcpy(nfo, info, sizeof(info)); //copy whole string 35 byte
memmove(nfo, &nfo[29], 7); //move the last 7 byte to nfo
memcpy(db_info, nfo, 7); //copy the 7byte nfo to db_info

is this correct?
thanks
 
hi,

you wrote as following:

memset(nfo, 0x00, sizeof(nfo));

but sizeof(nfo) = NULL, if you define it as string, you can get the length of it as strlen(nfo) after you valued it. so please paster your definition first.
 
thanks. it work now, i thought it was the array problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top