Link to home
Start Free TrialLog in
Avatar of cfans
cfans

asked on

C strings strncpy and memcpy

I'm having a problem with C strings I can't understand it..

I'm trying to get a section out of a string..

char section[5];

char tempString[32] = "123456ABCDEFGHIJKLMNOPQRSTUVWXYZ";

memcpy(section, tempString + 16, 5);

printf("%s", section);

I get KLMNOÖÿ¿`X@
ASKER CERTIFIED SOLUTION
Avatar of brettmjohnson
brettmjohnson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial