C¿Í C++°ü·Ã |
---|
Á¦¸ñ | ¹®ÀÚ¿ Æ÷ÀÎÅÍ¿Í ¹è¿ 1998/08/30 (15:19) |
À̸§ | ±èÈ¿¿ø |
¹øÈ£ | 15 |
Á¶È¸ | 697 |
º»¹® |
#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 |