C 언어에서 문자열과 문자 배열 및 실수의 상호 변환

8091 단어 c 언어
int main(){
     
	//char           ,      
	char ch[20] = " jakjfdkajkfljafsn";
	string s = ch;
	cout << s << endl;
	//     char  ,c_str()           
	printf("%s
"
,s.c_str()); // stringstream sstr; double x = 126.8932; sstr << x; s = sstr.str(); cout << s + "jakf"<< endl; // char char ch2[20] = "-12345.783"; char ch1[20] = "326"; double a1 = atof(ch2) + atoi(ch1); printf("%lf
"
, a1); char*itoa(int value,char*string,int radix); //itoa atoi ,int value ,char *string ,int radix , 2,8,10,16 int number=156; char str[10]; itoa(number,str,16); printf("%s
"
, str); // char str1[10] = "1234" ; int i; sscanf(str1, "%d", &i); // i printf("%d
"
, i+2); int data = 789; sprintf(str1,"%d",data);// data cout << str1 << endl; char str2[10] = "10"; sprintf(str1,"%s and %s
"
,str1, str2); // cout << str1 <<endl; }

좋은 웹페이지 즐겨찾기