unsigned long int strtol(const char *str, char **endptr, int base);
strtol, unsigned long int.
double strtod(const char *str, char **endptr);
double.
, , , .
, , atof, strtol, strtoul, strtod errno ERANGE. errno ERANGE math.h. atof strtod HUGE_VAL, strtol LONG_MAX LONG_MIN, strtoul ULONG_MAX.
itoa, ltoa, utoa, ecvt, fcvt gcvt. sprintf
int sprintf(char *buffer, const char *format,...);
, format buffer. , buffer, .
%[][][.][]
, ;
, ;
;
;
.
:
%[-][+|][][l]d
- , ;
+ +, , -;
;
l long;
d int.
:
%[-][#][][l][u|o|x|X]
# 0 8 c/c 0x 0X 16 c/c,
l long;
u 10c/c,
o 8 c/c,
x, X 16 c/c.
:
%[-] [+ | ][][.] [f | e | E | g | G]
'' f, e E g G. . ;
f ,
e , 'e',
E , 'E',
|
|
g f g,
G f G.
15 :
1. .
2. , , .
3.
- , .
- , , .
typedef.
, .
- , .
- , , .
typedef.
, .
- , .
. .
:
enum _ { }
.
0 1. , =
enum color {red, green, blue};
cout<<red<<' '<<blue<<' '<<green; // "0 2 1"
enum int.
- .
C++ , .
color d=0; //
. ().
.
struct __
{
;
//
}
Struct emp
{
int empno;
char value[10];
Double salary;
};
struct emp a; // C
emp a; // C++
.
struct emp a={10,"Paul",200.15};
, ( ).
(.).
a.empno=20;
strcpy(a.value,"John");
a.salaty=3000;
, .
Struct emp b;
b=a;