노력과 삽질 퇴적물

CPP: 문자열 본문

프로그래밍note/언어. C&C++ 계열

CPP: 문자열

MTG 2011. 10. 12. 21:28

문자열 출력

strcpy()

char str1[];
char str2[] = "문자배열로도도 덮어지기 가능.";
strcpy(str1, "새로 덮어씌워지는 문자열");
strcpy(str1, str2);



 
strcat()
char str3[] = "가나다라";
 
char str4[] = "마바사아";
 
strcat(str3, str4); // -> str3을 출력시, 가나다라마바사아




숫자변환

  int atoi (const char *nprt);
 
-> int n1 = atoi("1234"); //n1 = 1234;

 
long atol (const char *nprt);
 
-> long n2 = atil("-1234567");

 
float atof (const char *nprt);
 
-> float n3 = atof("1.234");