Tuesday, November 9, 2021

[字串處理] unsigned char myVar[10] to std::string

 #include <iostream>

#include <stdio.h>

#include <string.h>


int main()

{

    std::string strList;

    int itemCount = 10;

    int u8Index = 0;

    unsigned char myVar[10] = "abcdefg";


    for(u8Index = 0; u8Index < itemCount; u8Index++)

    {

    std::string res(myVar, myVar+strlen((char*)myVar));

    strList.append(res).append("\n");

    }

    std::cout << strList ;

}

No comments:

Post a Comment

n8n index

 【n8n免費本地端部署】Windows版|程式安裝x指令大補帖  【一鍵安裝 n8n】圖文教學,獲得無限額度自動化工具&限時免費升級企業版功能