请问int怎么转成char[],以及set有哪些函数
请教int如何转成char[],以及set有哪些函数?
如 int i = 123456;
结果应该是 char c[7]
c[0] = '1 ', c[1]=2 '....c[5]= '6 ',c[6]= '\0 '
请问这段程序怎么写? 或是有相关的函数可以用吗?
另外STL 的SET中有那些函数?请列举一下,谢谢。
------解决方案--------------------
1.sprintf(c, "%d ",i);
2.
Member Functions
begin
Returns an iterator that addresses the first element in the set.
clear
Erases all the elements of a set.
count
Returns the number of elements in a set whose key matches a parameter-specified key.
empty
Tests if a set is empty.
end
Returns an iterator that addresses the location succeeding the last element in a set.
equal_range
Returns a pair of iterators respectively to the first element in a set with a key that is greater than a specified key and to the first element in the set with a key that is equal to or greater than the key.
erase
Removes an element or a range of elements in a set from specified positions or removes elements that match a specified key.
find
Returns an iterator addressing the location of an element in a set that has a key equivalent to a specified key.
get_allocator
Returns a copy of the allocator object used to construct the set.
insert
Inserts an element or a range of elements into a set.
key_comp
Retrieves a copy of the comparison object used to order keys in a set.
lower_bound
Returns an iterator to the first element in a set with a key that is equal to or greater than a specified key.
max_size
Returns the maximum length of the set.
rbegin
Returns an iterator addressing the first element in a reversed set.
rend
Returns an iterator that addresses the location succeeding the last element in a reversed set.
size
Returns the number of elements in the set.
swap
Exchanges the elements of two sets.
upper_bound
Returns an iterator to the first element in a set with a key that is greater than a specified key.
value_comp
Retrieves a copy of the comparison object used to order element values in a set.
如 int i = 123456;
结果应该是 char c[7]
c[0] = '1 ', c[1]=2 '....c[5]= '6 ',c[6]= '\0 '
请问这段程序怎么写? 或是有相关的函数可以用吗?
另外STL 的SET中有那些函数?请列举一下,谢谢。
------解决方案--------------------
1.sprintf(c, "%d ",i);
2.
Member Functions
begin
Returns an iterator that addresses the first element in the set.
clear
Erases all the elements of a set.
count
Returns the number of elements in a set whose key matches a parameter-specified key.
empty
Tests if a set is empty.
end
Returns an iterator that addresses the location succeeding the last element in a set.
equal_range
Returns a pair of iterators respectively to the first element in a set with a key that is greater than a specified key and to the first element in the set with a key that is equal to or greater than the key.
erase
Removes an element or a range of elements in a set from specified positions or removes elements that match a specified key.
find
Returns an iterator addressing the location of an element in a set that has a key equivalent to a specified key.
get_allocator
Returns a copy of the allocator object used to construct the set.
insert
Inserts an element or a range of elements into a set.
key_comp
Retrieves a copy of the comparison object used to order keys in a set.
lower_bound
Returns an iterator to the first element in a set with a key that is equal to or greater than a specified key.
max_size
Returns the maximum length of the set.
rbegin
Returns an iterator addressing the first element in a reversed set.
rend
Returns an iterator that addresses the location succeeding the last element in a reversed set.
size
Returns the number of elements in the set.
swap
Exchanges the elements of two sets.
upper_bound
Returns an iterator to the first element in a set with a key that is greater than a specified key.
value_comp
Retrieves a copy of the comparison object used to order element values in a set.