close

char[]轉成char*

參考網址:http://stackoverflow.com/questions/9627962/is-it-possible-to-convert-char-to-char-in-c

最簡單方法(wchar_t也適用)

method1:
char a[] = "hello";  
char* p = &a[0];

method2:(避免method1的值一出scope就消失)
char a[] = "hello"; 
char* p;
p = strdup(a);

 

arrow
arrow
    文章標籤
    char[] to char*
    全站熱搜

    跪著讀 發表在 痞客邦 留言(0) 人氣()