⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_yc_string.c

📁 一个类STL的多平台可移植的算法容器库,主要用于嵌入式系统编程时的内存管理等方面
💻 C
📖 第 1 页 / 共 2 页
字号:
                break;
            case 15:
            {
                size_t new_capa = 0;
                printf( "please input new capacity\n" );
                scanf( "%u", &new_capa );
                if( false == testwchar )
                    ncstr_reserve( &str, new_capa );
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                    wcstr_reserve( &wstr, new_capa );
#endif
                break;
            }
            case 16:
            {
                size_t pos = 0;
                printf( "please input index:\n" );
                scanf( "%u", &pos );
                if( false == testwchar )
                    ncstr_erase_pos( &str, pos );
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                    wcstr_erase_pos( &wstr, pos );
#endif
                break;
            }
            case 17:
            {
                size_t first = 0, last = 0;
                printf( "please input first index:\n" );
                scanf( "%u", &first );
                printf( "please input last index:\n" );
                scanf( "%u", &last );
                if( false == testwchar )
                    ncstr_erase_range( &str, first, last );
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                    wcstr_erase_range( &wstr, first, last );
#endif
                break;
            }
            case 18:
            {
                size_t index = 0, count = 0;
                printf( "please input insert index:\n" );
                scanf( "%u", &index );
                printf( "please input insert count:\n" );
                scanf( "%u", &count );
                if( false == testwchar )
                {
                    char getc[8];
                    printf( "please input a character\n" );
                    scanf( "%s", getc );
                    ncstr_insert_value( &str, index, getc[0], count );
                }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                {
                    wchar_t getwc[8];
                    printf( "please input a wide character\n" );
                    wscanf( L"%ls", getwc );
                    wcstr_insert_value( &wstr, index, getwc[0], count );
                }
#endif
                break;
            }
            case 19:
            {
                size_t index = 0, count = 0;
                printf( "please input insert index:\n" );
                scanf( "%u", &index );
                printf( "please input insert count:\n" );
                scanf( "%u", &count );
                if( false == testwchar )
                {
                    char s[256];
                    printf( "please input a string\n" );
                    scanf( "%s", s );
                    ncstr_insert_array( &str, index, s, count );
                }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                {
                    wchar_t ws[256];
                    printf( "please input a wide string\n" );
                    wscanf( L"%ls", ws );
                    wcstr_insert_array( &wstr, index, ws, count );
                }
#endif
                break;
            }
            case 20:
            {
                size_t len = 0;
                printf( "please input new size:\n" );
                scanf( "%u", &len );
                if( false == testwchar )
                {
                    char getc[8];
                    printf( "please input a character\n" );
                    scanf( "%s", getc );
                    ncstr_resize( &str, len, getc[0] );
                }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                {
                    wchar_t getwc[8];
                    printf( "please input a wide character\n" );
                    wscanf( L"%ls", getwc );
                    wcstr_resize( &wstr, len, getwc[0] );
                }
#endif
                break;
            }
            case 21:
            {
                size_t index = 0, old_count = 0, new_count = 0;
                printf( "please input replace index:\n" );
                scanf( "%u", &index );
                printf( "please input old count:\n" );
                scanf( "%u", &old_count );
                printf( "please input new count:\n" );
                scanf( "%u", &new_count );
                if( false == testwchar )
                {
                    char getc[8];
                    printf( "please input a character\n" );
                    scanf( "%s", getc );
                    ncstr_replace_fill( &str, index, old_count, getc[0], new_count );
                }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                {
                    wchar_t getwc[8];
                    printf( "please input a wide character\n" );
                    wscanf( L"%ls", getwc );
                    wcstr_replace_fill( &wstr, index, old_count, getwc[0], new_count );
                }
#endif
                break;
            }
            case 22:
            {
                size_t index = 0, old_count = 0, new_count = 0;
                printf( "please input replace index:\n" );
                scanf( "%u", &index );
                printf( "please input old count:\n" );
                scanf( "%u", &old_count );
                printf( "please input new count:\n" );
                scanf( "%u", &new_count );
                if( false == testwchar )
                {
                    char s[256];
                    printf( "please input a string\n" );
                    scanf( "%s", s );
                    ncstr_replace_array( &str, index, old_count, s, new_count );
                }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                {
                    wchar_t ws[256];
                    printf( "please input a wide string\n" );
                    wscanf( L"%ls", ws );
                    wcstr_replace_array( &wstr, index, old_count, ws, new_count );
                }
#endif
                break;
            }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_INPUT_OUTPUT_SYSTEM__
            case 23:
            {
                if( false == testwchar )
                {
                    printf( "please input a string:\n" );
                    getchar();
                    ncstr_getline( &str, '\n' );
                    printf( "%s\n", ncstr_to_string(&str) );
                }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                {
                    printf( "please input a string:\n" );
                    getwchar();
                    wcstr_getline( &wstr, '\n' );
                    wprintf( L"%ls\n", wcstr_to_wstring(&wstr) );
                }
#endif
                break;
            }
#endif
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_FILE_SYSTEM__
            case 24:
            {
                char filepath[512];
                FILE* fp;
                printf( "please input file path and name\n" );
                scanf( "%s", filepath );
                fp = fopen( filepath, "r" );
                if( fp )
                {
                    if( false == testwchar )
                    {
                        while( !feof(fp) )
                        {
                            ncstr_fgetline( &str, fp, '\n' );
                            printf( "%s\n", ncstr_to_string(&str) );
                        }
                    }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                    else
                    {
                        while( !feof(fp) )
                        {
                            wcstr_fgetline( &wstr, fp, '\n' );
                            wprintf( L"%ls\n", wcstr_to_wstring(&wstr) );
                        }
                    }
#endif
                    fclose( fp );
                }
                break;
            }
#endif
            case 25:
                if( false == testwchar )
                {
                    ncstr_format( &str, "long double min: %.6e", ldmin );
                    printf( "size: %u;  capacity: %u;  %s\n",
                            ncstr_size(&str), ncstr_capacity(&str),
                            ncstr_to_string(&str) );
                    ncstr_format( &str, "long double max: %.6e", ldmax );
                    printf( "size: %u;  capacity: %u;  %s\n",
                            ncstr_size(&str), ncstr_capacity(&str),
                            ncstr_to_string(&str) );
                    ncstr_format( &str, "long double min: %.Lf", ldmin );
                    printf( "size: %u;  capacity: %u;  %s\n",
                            ncstr_size(&str), ncstr_capacity(&str),
                            ncstr_to_string(&str) );
                    ncstr_format( &str, "long double max: %.Lf", ldmax );
                    printf( "size: %u;  capacity: %u;  %s\n",
                            ncstr_size(&str), ncstr_capacity(&str),
                            ncstr_to_string(&str) );
                }
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                {
                    wcstr_format( &wstr, L"long double min: %.6e", ldmin );
                    wprintf( L"size: %u;  capacity: %u;  %s\n",
                             wcstr_size(&wstr), wcstr_capacity(&wstr),
                             wcstr_to_wstring(&wstr) );
                    wcstr_format( &wstr, L"long double max: %.6e", ldmax );
                    wprintf( L"size: %u;  capacity: %u;  %s\n",
                             wcstr_size(&wstr), wcstr_capacity(&wstr),
                             wcstr_to_wstring(&wstr) );
                    wcstr_format( &wstr, L"long double min: %.Lf", ldmin );
                    wprintf( L"size: %u;  capacity: %u;  %s\n",
                             wcstr_size(&wstr), wcstr_capacity(&wstr),
                             wcstr_to_wstring(&wstr) );
                    wcstr_format( &wstr, L"long double max: %.Lf", ldmax );
                    wprintf( L"size: %u;  capacity: %u;  %s\n",
                             wcstr_size(&wstr), wcstr_capacity(&wstr),
                             wcstr_to_wstring(&wstr) );
                }
#endif
                break;
            case 26:
                if( false == testwchar )
                    printf( "str: %s\n", ncstr_to_string(&str) );
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                    wprintf( L"wstr: %ls\n", wcstr_to_wstring(&wstr) );
#endif
                break;
            case 27:
                if( false == testwchar )
                    ncstr_put( &str );
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
                else
                    wcstr_put( &wstr );
#endif
                putchar( '\n' );
                break;
            default:
                break;
        }

        printf( "\npress any key to continue\n" );
/*        pool_print();*/
        getchar();
        getchar();
    };

EXIT:
    ncstr_destroy( &str );
#ifdef __MACRO_C_YOUNG_LIBRARY_COMPILER_SUPPORT_C95_WIDE_CHARACTER__
    wcstr_destroy( &wstr );
#endif
    printf( "\n\n\n" );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -