C語言字符串內存問題

#include <stdio.h>

int main(void){
    char * a = {"hello"};
    char * b = {'h','f','\0'};
    char * c = {'h','f'};
    char * e = {'h','f',' '};
    printf("%d\n",strlen(a));
     //printf("%d",strlen(b)); //內存出錯
     // printf("%d",strlen(c)); //內存出錯
      //printf("%s\n",b);   //出錯
      //printf("%d\n",strlen(e)); //出錯

    char d[10] ={'a','b'};
    for(int i =0;i<10 ;++i){
        printf("%c\n",d[i]);
    }
    printf("%d\n",strlen(d));
    return 0;

}

待定

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章