In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In order to solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Long long_data=-9828
Unsigned char data [4]
Memcpy (data,&t,4); / / save data of type long with 4 char.
Long my_long_data=0
Memcpy (& tt,data,4); / / restore long type data from 4 char.
1. Convert int/long/float/double to string
Method 1:itoa, ltoa (a represents the meaning of array array)
Header file: stdlib.h
Example:
Int a = 3
Long b = 23
Char buf1 [30] = ""
Itoa (a, buf1, 10); / / 10 means decimal, and the content saved by buf1 is "3"
Char buf2 [30] = ""
Ltoa (b, buf2, 10); / / 10 means decimal, and the content saved by buf2 is "32"
Method 2:sprintf
Header file: stdio.h
Example:
Int a = 3
Float b = 4.2f
Char buf [30] = ""
Sprintf (buf, "% djue% f", a, b); / / the content saved by buf is "3djue 4.2", which can be compared with printf
Method 3:ostringstream
Header file: # include
Using namespace std
Example:
Int a = 3
Float b = 4.2f
Ostringstream s1
S1
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.