Novice C language learning journey

梦幻光晕蓝色背景矢量图.png
At first i do not know why the b array output result is different for the two code as follows.
No long after,i found that because the b array is out of bounds.The b array is only include five elements.So only has five print result is valid for the b array.
the first code as follows:
#include"stdio.h"
#include"stdlib.h"
int main(void){

char b[5]={"hello world"};
int i;
i=0;
while(i<=15){
    printf("%c=%d\n",b[i],b[i]);
    i++;
    }
return 0;
system("pause");

}
捕获.PNG
the second code as follows:
#include"stdio.h"
#include"stdlib.h"
int main(void){

char b[5]={"hello world"};
int i=0;
while(i<=15){
    printf("%c=%d\n",b[i],b[i]);
    i++;
    }
return 0;
system("pause");

}
11.PNG

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center