작성
·
395
0
char words[MAXLENGTH] = "A string in an array";
const char* pt1 = "A pointer to a string."; // point the first address of sentence
puts("Puts() adds a newline at the end: "); // puts() add \n at the end
puts(MESSAGE);
puts(words); // char words[21] removes this warning -> Total 81 sizes but, only 21 sizes are initialized
puts(pt1);
words[3] = 'p'; // OK
puts(words);
//pt1[8] = 'A'; // Runtime Error 건들이면 안되는 부분임
puts(pt1);
char greeting[50] = "Hello, and" " How are" " you"
" today!"; //아래 코드와 같음.
//char greeting[50] = "Hello, and How are you today!";
puts(greeting);
printf("%s, %p, %c\n", "We", "are", *"excellent programmers");
char cookies[1] = { 'A', }; //char cookies[1] = {'A'}; 도 같은 결과가 나옴
puts(cookies);
위 코드를 실행해보니
이렇게 출력되더라고요
그리고 puts(cookies); 에 초록색 밑줄로 String 'cookies' might not be zero-terminated. 라고 나옵니다.
어디서 문제가 발생한건지, Hello, and How are you today! 는 왜 한번 더 출력된건지 궁금합니다.