int-string 형 변환

Int to string
Integer to string
itoa
int_to_str
Integer.toString
Int-string 변환

1 C[ | ]

#include<stdio.h>
int main() {
  char buf[BUFSIZ];
  sprintf(buf, "%d", 42);
  printf("%s\n", buf);
  // 42
}

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
	int x = 42;
	string s = to_string(x);
	cout << s;
}

3 C#[ | ]

int i = 42;
string str = i.ToString();

4 Java[ | ]

int i = 42;
String str = String.valueOf(i);
int i = 42;
String str = Integer.toString(i);
int i = 42;
String str = "" + i;

5 JavaScript[ | ]

var num = 15;
var n = num.toString();

6 Objective-C[ | ]

int i = 42;
NSString* str = [NSString stringWithFormat:@"%d", i];

7 Perl[ | ]

$i = 42;
$s = "$i";

8 PHP[ | ]

$i = 42;
$s = "$i";

9 Python[ | ]

i = 42
s = str(i)

10 Ruby[ | ]

i = 42
str = i.to_s

11 VB[ | ]

Dim i As Integer
Dim str As String

i = 42
str = Str(i)

12 같이 보기[ | ]