?
Hi !
Check this out:
// from, to inclusive.
int StrPosCpy( const char* src, char* buf, unsigned bufsize,
unsigned from, unsigned to )
{
if ( to > ( strlen(src) - 1 ) )
return 1;
if ( ( to - from + 2 ) > bufsize )
return 1;
memset ( buf, 0, bufsize ); // Nullterminierung sicherstellen.
strncpy( buf, src + from, to - from + 1 );
return 0;
}
int main()
{
char a[200] = {0}, b[200] = {0};
int x = 3, y = 7;
strcpy ( a, "Hallo, das ist eine demo!" );
StrPosCpy( a, b, sizeof(b), x, y );
puts( b );
return 0;
}