Programming
| No. | 146 |
| Name. | swindler |
| Subject. | 문자열 포인터와 배열 (String, Pointer, Array) |
| Main Cate. | C/C++ |
| Sub Cate. | |
| Date. | 2005-07-06 11:15 |
| Hit. | 3220 (211.109....) |
| File. | |
| #include <stdio.h> #include <iostream.h> #include <string.h> void main(void) { char *source1; char source2[25]; source1="Source String1"; strcpy(source2,"Source String2"); cout<<source1<<endl; cout<<source2<<endl; cout<<"length of source1="<<strlen(source1)<<endl; cout<<"length of source2="<<strlen(source2)<<endl; cout<<"size of char ="<<sizeof(char)<<endl; cout<<"size of char* ="<<sizeof(char*)<<endl; cout<<"size of source1="<<sizeof(source1)<<endl; cout<<"size of source2="<<sizeof(source2)<<endl; cout<<"5th String of source1="<<(source1+4)<<endl; printf("5th Character of source1=%c\n",*(source1+4)); cout<<"5th String of source2="<<(source2+4)<<endl; cout<<"5th Character of source2="<<source2[4]<<endl; printf("5th Character of souece2=%c\n",*(source2+4)); source1="Changed1"; strcpy(source2,"Changed2"); cout<<endl<<"After Change of string"<<endl; cout<<source1<<endl; cout<<source2<<endl; //출력 Source String1 Source String2 length of source1=14 length of source2=14 size of char =1 size of char* =4 size of source1=4 size of source2=25 5th String of source1=ce String1 5th Character of source1=c 5th String of source2=ce String2 5th Character of source2=c 5th Character of souece2=c After Change of string Changed1 Changed2 [바로가기 링크] : http://coolx.net/cboard/develop/146 |
|
|
|
|
| [Modify] [Delete] | [Reply] [List] | |



Copyright © 1999-2017, swindler. All rights reserved.
367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)