Advertisement

Copying Strings

Started by February 16, 2001 09:58 AM
1 comment, last by Bleakcabal 23 years, 11 months ago
Does anyone know how to copy the characters say from 44 to 66 in source string to destination string ? strncpy starts at the start of the string I have checked there is a function called _strninc but the compiler doesn''t seem to reconize it, I include tchar.h and string.h and tried it without the leading underscore. This function though is only supposed to advance the character pointed at, but that would have served my purpose. WHO DO THEY THINK THEY''RE FOOLING : YOU ?
GARAL website
WHO DO THEYTHINK THEY'REFOOLING : YOU ?
int start_offset = 44;
int end_offset = 66;
char source_string[81];
char dest_string[81];
/* fill source_string with character data or whatever */
strncpy(dest_string, &source_string[start_offset], end_offset-start_offset+1);

/* or do it this way */
strncpy(dest_string, source_string+start_offset, end_offset-start_offset+1);


Edited by - Mongo on February 16, 2001 11:34:13 AM
Advertisement
Thank you !

WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?



GARAL website
WHO DO THEYTHINK THEY'REFOOLING : YOU ?

This topic is closed to new replies.

Advertisement