(clang) string shuffling
This commit is contained in:
+13
-6
@@ -7,11 +7,18 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int array[ARRAY_SIZE] = { 0 };
|
||||
int n;
|
||||
char string[256];
|
||||
char blargh[] = "hello.world";
|
||||
char* temp;
|
||||
size_t len;
|
||||
|
||||
for ( n = 0; n < ARRAY_SIZE; n++ )
|
||||
{
|
||||
printf( "array[%d] = %d;\n", n, array[n] );
|
||||
}
|
||||
temp = strrchr( blargh, '.' );
|
||||
len = strlen( temp );
|
||||
|
||||
printf( "temp[ %ld ] = %s\n", len, &temp[ 1 ] );
|
||||
|
||||
strncpy( &string[ 0 ], &temp[ 1 ], len - 1 );
|
||||
strncpy( &string[ len - 1 ], blargh, ( size_t )( temp - blargh ) );
|
||||
|
||||
printf( "string = %s\n", string );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user