(clang) string shuffling

This commit is contained in:
2026-07-21 22:37:23 +02:00
parent 90fc9cac0d
commit 71e9ae509c
+13 -6
View File
@@ -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 );
}