Advertisement

如何在所需位置插入换行符

阅读量:

前言:主主要为绕AWTK进行开发,单纯c/C++可做参考

在这里插入图片描述

产品ui新加需求,围绕将其换行进行编写

复制代码
    void insert_newline_at_index(char* str, int index)
    {
    memmove(str + index + 1, str + index, strlen(str) - index + 1); // 后移 index 之后的所有字符,包括字符串结束符
    str[index] = '\n'; // 在 index 处插入换行符
    }
    
    
    AI写代码c
    
    运行
复制代码
    int sizeof_device_name(char* name)
    {
    size_t length = strlen(name);
    printf("传入的字符长度 %d\n", length);
    
    if (length > 64) {
        printf("当前传入设备名:%s 名长度超过64,请修改设备名长

全部评论 (0)

还没有任何评论哟~