"C언어 문자열 배열"의 두 판 사이의 차이

(새 문서: ==개요== ;C언어 문자열 배열 <source lang='c'> #include <stdio.h> int main() { char *words[1000]; words[0] = "Hello"; words[1] = "World"; words[2] = "Hello"; int count...)
 
잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 13개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;C언어 문자열 배열
;C언어 문자열 배열


<source lang='c'>
<syntaxhighlight lang='c'>
#include <stdio.h>
#include <stdio.h>
 
void main() {
int main() {
char *words[3];
char *words[1000];
words[0] = "Alice";
words[0] = "Hello";
words[1] = "Bob";
words[1] = "World";
words[2] = "Carol";
words[2] = "Hello";
for( int i=0; i<3; i++ ) printf( "%s\n", words[i] );
int count = 3;
// Alice
 
// Bob
for( int i=0; i<count; i++ ) {
// Carol
printf( "%s\n", words[i] );
}
}
</syntaxhighlight>
<syntaxhighlight lang='c'>
#include <stdio.h>
void main() {
char *words[3] = {"Alice", "Bob", "Carol"};
for( int i=0; i<3; i++ ) printf( "%s\n", words[i] );
}
</syntaxhighlight>
<syntaxhighlight lang='c'>
#include <stdio.h>
void main() {
char *words[] = {"Alice", "Bob", "Carol"};
for( int i=0; i<3; i++ ) printf( "%s\n", words[i] );
}
}
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[C언어 단어 추출]]
* [[C언어 단어 추출]]
* [[C언어 배열 길이 구하기]]


[[분류: C 문자열]]
[[분류:C 문자열]]
[[분류:C 배열]]

2020년 11월 2일 (월) 02:41 기준 최신판

1 개요[ | ]

C언어 문자열 배열
#include <stdio.h>
void main() {
	char *words[3];
	words[0] = "Alice";
	words[1] = "Bob";
	words[2] = "Carol";
	for( int i=0; i<3; i++ ) printf( "%s\n", words[i] );
	// Alice
	// Bob
	// Carol
}
#include <stdio.h>
void main() {
	char *words[3] = {"Alice", "Bob", "Carol"};
	for( int i=0; i<3; i++ ) printf( "%s\n", words[i] );
}
#include <stdio.h>
void main() {
	char *words[] = {"Alice", "Bob", "Carol"};
	for( int i=0; i<3; i++ ) printf( "%s\n", words[i] );
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}