컴퓨터 과학 & 영상처리 관련/C / C++
sprintf 예제
꺄뜨르
2012. 8. 21. 16:18
int _tmain(int argc, _TCHAR* argv[]) {
char* temp = "HI";
char temp1[100];
sprintf(temp1,"%s%s","HIHI",temp);
printf("%s\n",temp1);
for(int i = 0 ; i < strlen(temp1) ; i++)
printf("%d %c\n",i,temp1[i]);
printf("\n");
sprintf(temp1,"%s",temp);
printf("%s\n",temp1);
for(int i = 0 ; i < strlen(temp1) ; i++)
printf("%d %c\n",i,temp1[i]);
return 0;
}
결과
HIHIHI
0 H
1 I
2 H
3 I
4 H
5 I
HI
0 H
1 I
계속하려면 아무 키나 누르십시오 . . .