There’s a core function for that: get_post_types()
:
<?php get_post_types( $args, $output, $operator ); ?>
So, for example, to return public, custom post types by name:
$custom_post_types = get_post_types( array(
// Set to FALSE to return only custom post types
'_builtin' => false,
// Set to TRUE to return only public post types
'public' => true
) );