8 Strings Arrays and Pointers Strings n String

  • Slides: 15
Download presentation
8주차: Strings, Arrays and Pointers

8주차: Strings, Arrays and Pointers

Strings n 문자열(String) n “I am a boy. ”, “String”, “”(Null string), . .

Strings n 문자열(String) n “I am a boy. ”, “String”, “”(Null string), . . . n n NULL string은 비어 있는 string이라고 생각하 면 된다. 문자열(string)은 문자(character)의 집합이 다.

A Type Cast Example #include<stdio. h> #define STUDENT_NUM 74 int main(void) { int sn

A Type Cast Example #include<stdio. h> #define STUDENT_NUM 74 int main(void) { int sn = STUDENT_NUM; int total_score = 6750; float avg_score; avg_score = (float) total_score / (float) sn; printf(“Average score is %. 2 fn”, avg_score); return 0; } -이 프로그램은 평균점수를 계 산할 때 type cast를 한다. total_score를 실수로 타입변환 하면 6750. 0이 된다. sn을 실수 로 변환하면 74. 0이 된다. -이제 (float) total_score / (float) sn은 실수수식이며 6750. 0 / 74. 0 = 91. 22. . . 라는 값을 가진 다. -이 프로그램은 91. 22를 화면에 출력한다.