Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of string, Integer and floating Point conversion in C++

Shulou Source: shulou.com Published: 2022-06-03 15:14:11 11月01日 Update

This article mainly introduces the C++ string and integer and floating-point conversion example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article. Next, let the editor take you to know about it.

1. String and char [] 1. String to char []

String is a class, while the variable name of char [] is essentially an address, which at first glance doesn't seem easy to convert.

But in fact, we can migrate the values in string to char [] as a whole by address:

# include # include using namespace std;int main () {string s = "123.123"; char a [101l]; strcpy (a, s.c_str ()); / / strcpy (a, s.data ()); / / equivalent to the above statement, you can cout either of them

Tags: Output character string function code floating point article no content address binary competition example clocking analysis special three two only numbers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Information Shulou Technology Redmi Shulou Tech Info