(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 main(void)
{ {
int array[ARRAY_SIZE] = { 0 }; char string[256];
int n; char blargh[] = "hello.world";
char* temp;
size_t len;
for ( n = 0; n < ARRAY_SIZE; n++ ) temp = strrchr( blargh, '.' );
{ len = strlen( temp );
printf( "array[%d] = %d;\n", n, array[n] );
} 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 );
} }