首页 > 编程知识 正文

c语言tostring头文件,c++ cstring头文件

时间:2024-03-07 18:23:12 阅读:331526 作者:COIU

本文目录一览:

C语言头文件,conio.h,windows.h,string.h,math.h各有什么用?

conio.h不是C标准库中的头文件。 conio是Console Input/Output(控制台输入输出)的简写,其中定义了通过控制台进行数据输入和数据输出的函数,主要是一些用户通过按键盘产生的对应操作,比如getch()函数等等。

[编辑本段]包含的函数

包含的函数: cgets(char *); cprintf(const char *, ...); cputs(const char *); cscanf(const char *, ...); inp(unsigned short); inpw(unsigned short); getch(void); getche(void); kbhit(void); outp(unsigned short, int); outpw(unsigned short, unsigned short); putch(int); ungetch(int); void _Cdecl clreol (void); void _Cdecl clrscr (void); void _Cdecl delline (void); int _Cdecl gettext (int left, int top, int right, int bottom, void *destin); void _Cdecl gettextinfo (struct text_info *r); void _Cdecl gotoxy (int x, int y); void _Cdecl highvideo (void); void _Cdecl insline (void); void _Cdecl lowvideo (void); int _Cdecl movetext (int left, int top, int right, int bottom, int destleft, int desttop); void _Cdecl normvideo (void); int _Cdecl puttext (int left, int top, int right, int bottom, void *source); void _Cdecl textattr (int newattr); void _Cdecl textbackground (int newcolor); void _Cdecl textcolor (int newcolor); void _Cdecl textmode (int newmode); int _Cdecl wherex (void); int _Cdecl wherey (void); void _Cdecl window (int left, int top, int right, int bottom); har *_Cdecl cgets (char *str); int _Cdecl cprintf (const char *format, ...); int _Cdecl cputs (const char *str); int _Cdecl cscanf (const char *format, ...); int _Cdecl getch (void); int _Cdecl getche (void); char *_Cdecl getpass (const char *prompt); int _Cdecl kbhit (void); int _Cdecl putch (int c); int _Cdecl ungetch (int ch);

windows.h

Windows程序的开头都可看到: #include windows.h WINDOWS.H是主要的头文件,它包含了其他Windows头文件,这些头文件的某些也包含了其他头文件。这些头文件中最重要的和最基本的是: WINDEF.H 基本型态定义。 WINNT.H 支援Unicode的型态定义。 WINBASE.H Kernel函数。 WINUSER.H 使用者介面函数。 WINGDI.H 图形装置介面函数。 这些头文件定义了Windows的所有资料型态、函数调用、资料结构和常数识别字,它们是Windows文件中的一个重要部分。

[编辑本段]文件内容

/*++ BUILD Version: 0001 Increment this if a change has global effects Copyright (c) Microsoft Corporation. All rights reserved. Module Name: windows.h Abstract: Master include file for Windows applications. --*/ #ifndef _WINDOWS_ #define _WINDOWS_ #ifdef __BORLANDC__ #pragma defineonoption __BOROPT_A -A #pragma defineonoption __BOROPT_H -H #if (__BORLANDC__ == 0x550) defined(__BOROPT_A) defined(__BOROPT_H) #error The use of both -A (ANSI mode) and -H (pre-compiled headers) at the same time is unsupported. #endif #endif /* __BORLANDC__ */ #pragma option push -b -a8 -pc -A- /*P_O_Push*/ #ifndef WINVER #define WINVER 0x0501 #else #if defined(_WIN32_WINNT) (WINVER 0x0400) (_WIN32_WINNT 0x0400) #error WINVER setting conflicts with _WIN32_WINNT setting #endif #endif #ifndef _INC_WINDOWS #define _INC_WINDOWS #if defined (_MSC_VER) (_MSC_VER = 1020) #pragma once #endif /* If defined, the following flags inhibit definition * of the indicated items. * * NOGDICAPMASKS - CC_*, LC_*, PC_*, CP_*, TC_*, RC_ * NOVIRTUALKEYCODES - VK_* * NOWINMESSAGES - WM_*, EM_*, LB_*, CB_* * NOWINSTYLES - WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_* * NOSYSMETRICS - SM_* * NOMENUS - MF_* * NOICONS - IDI_* * NOKEYSTATES - MK_* * NOSYSCOMMANDS - SC_* * NORASTEROPS - Binary and Tertiary raster ops * NOSHOWWINDOW - SW_* * OEMRESOURCE - OEM Resource values * NOATOM - Atom Manager routines * NOCLIPBOARD - Clipboard routines * NOCOLOR - Screen colors * NOCTLMGR - Control and Dialog routines * NODRAWTEXT - DrawText() and DT_* * NOGDI - All GDI defines and routines * NOKERNEL - All KERNEL defines and routines * NOUSER - All USER defines and routines * NONLS - All NLS defines and routines * NOMB - MB_* and MessageBox() * NOMEMMGR - GMEM_*, LMEM_*, GHND, LHND, associated routines * NOMETAFILE - typedef METAFILEPICT * NOMINMAX - Macros min(a,b) and max(a,b) * NOMSG - typedef MSG and associated routines * NOOPENFILE - OpenFile(), OemToAnsi, AnsiToOem, and OF_* * NOSCROLL - SB_* and scrolling routines * NOSERVICE - All Service Controller routines, SERVICE_ equates, etc. * NOSOUND - Sound driver routines * NOTEXTMETRIC - typedef TEXTMETRIC and associated routines * NOWH - SetWindowsHook and WH_* * NOWINOFFSETS - GWL_*, GCL_*, associated routines * NOCOMM - COMM driver routines * NOKANJI - Kanji support stuff. * NOHELP - Help engine interface. * NOPROFILER - Profiler interface. * NODEFERWINDOWPOS - DeferWindowPos routines * NOMCX - Modem Configuration Extensions */ #if defined(RC_INVOKED) !defined(NOWINRES) #include winresrc.h #else #if defined(RC_INVOKED) /* Turn off a bunch of stuff to ensure that RC files compile OK. */ #define NOATOM #define NOGDI #define NOGDICAPMASKS #define NOMETAFILE #define NOMINMAX #define NOMSG #define NOOPENFILE #define NORASTEROPS #define NOSCROLL #define NOSOUND #define NOSYSMETRICS #define NOTEXTMETRIC #define NOWH #define NOCOMM #define NOKANJI #define NOCRYPT #define NOMCX #endif #if defined(__BORLANDC__) defined(__cplusplus) # include mem.h // Needed for protos of memxxx() routines #endif #if defined(__BORLANDC__) # ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0500 /* If not set, assume NT 5.00 */ # endif # if defined(__cplusplus) # define NOMINMAX /* for WINDEF.H */ # else # define NONAMELESSUNION /* for OAIDL.H, OBJIDL.H,... */ # endif # if defined(_UNICODE) # define UNICODE # endif #endif #if !defined(_68K_) !defined(_MPPC_) !defined(_X86_) !defined(_IA64_) !defined(_AMD64_) defined(_M_IX86) #define _X86_ #endif #if !defined(_68K_) !defined(_MPPC_) !defined(_X86_) !defined(_IA64_) !defined(_AMD64_) defined(_M_AMD64) #define _AMD64_ #endif #if !defined(_68K_) !defined(_MPPC_) !defined(_X86_) !defined(_IA64_) !defined(_AMD64_) defined(_M_M68K) #define _68K_ #endif #if !defined(_68K_) !defined(_MPPC_) !defined(_X86_) !defined(_IA64_) !defined(_AMD64_) defined(_M_MPPC) #define _MPPC_ #endif #if !defined(_68K_) !defined(_MPPC_) !defined(_X86_) !defined(_M_IX86) !defined(_AMD64_) defined(_M_IA64) #if !defined(_IA64_) #define _IA64_ #endif // !_IA64_ #endif #ifndef _MAC #if defined(_68K_) || defined(_MPPC_) #define _MAC #endif #endif #if defined (_MSC_VER) #if ( _MSC_VER = 800 ) #ifndef __cplusplus #pragma warning(disable:4116) // TYPE_ALIGNMENT generates this - move it // outside the warning push/pop scope. #endif #endif #endif #ifndef RC_INVOKED #if ( _MSC_VER = 800 ) || defined(__BORLANDC__) #pragma warning(disable:4514) #ifndef __WINDOWS_DONT_DISABLE_PRAGMA_PACK_WARNING__ #pragma warning(disable:4103) #endif #if _MSC_VER = 1200 #pragma warning(push) #endif #pragma warning(disable:4001) #pragma warning(disable:4201) #pragma warning(disable:4214) #endif #include excpt.h #include stdarg.h #endif /* RC_INVOKED */ #include windef.h #include winbase.h #include wingdi.h #include winuser.h #if !defined(_MAC) || defined(_WIN32NLS) #include winnls.h #endif #ifndef _MAC #include wincon.h #include winver.h #endif #if !defined(_MAC) || defined(_WIN32REG) #include winreg.h #endif #ifndef _MAC #include winnetwk.h #endif #ifndef WIN32_LEAN_AND_MEAN #include cderr.h #include dde.h #include ddeml.h #include dlgs.h #ifndef _MAC #include lzexpand.h #include mmsystem.h #include nb30.h #include rpc.h #endif #include shellapi.h #ifndef _MAC #include winperf.h #include winsock.h #endif #ifndef NOCRYPT #include wincrypt.h #include winefs.h #include winscard.h #endif #ifndef NOGDI #ifndef _MAC #include winspool.h #ifdef INC_OLE1 #include ole.h #else #include ole2.h #endif /* !INC_OLE1 */ #endif /* !MAC */ #include commdlg.h #endif /* !NOGDI */ #endif /* WIN32_LEAN_AND_MEAN */ #include stralign.h #ifdef _MAC #include winwlm.h #endif #ifdef INC_OLE2 #include ole2.h #endif /* INC_OLE2 */ #ifndef _MAC #ifndef NOSERVICE #include winsvc.h #endif #if(WINVER = 0x0400) #ifndef NOMCX #include mcx.h #endif /* NOMCX */ #ifndef NOIME #include imm.h #endif #endif /* WINVER = 0x0400 */ #endif #ifndef RC_INVOKED #if ( _MSC_VER = 800 ) || defined(__BORLANDC__) #if _MSC_VER = 1200 #pragma warning(pop) #else #pragma warning(default:4001) #pragma warning(default:4201) #pragma warning(default:4214) /* Leave 4514 disabled. It's an unneeded warning anyway. */ #endif #endif #endif /* RC_INVOKED */ #endif /* RC_INVOKED */ #endif /* _INC_WINDOWS */ #pragma option pop /*P_O_Pop*/ #endif /* _WINDOWS_ */

string.h

C语言里面关于字符数组的函数定义的头文件,常用函数有strlen、strcmp、strcpy等等,更详细的可以到include文件夹里面查看该文件。 下面更详细的介绍下: /***********************************************************************/ C、传统 C++ #include assert.h //设定插入点 #include ctype.h //字符处理 #include errno.h //定义错误码 #include float.h //浮点数处理 #include fstream.h //文件输入/输出 #include iomanip.h //参数化输入/输出 #include iostream.h //数据流输入/输出 #include limits.h //定义各种数据类型最值常量 #include locale.h //定义本地化函数 #include math.h //定义数学函数 #include stdio.h //定义输入/输出函数 #include stdlib.h //定义杂项函数及内存分配函数 #include string.h //字符串处理 #include strstrea.h //基于数组的输入/输出 #include time.h //定义关于时间的函数 #include wchar.h //宽字符处理及输入/输出 #include wctype.h //宽字符分类 /***********************************************************************/ 标准 C++ (同上的不再注释) #include algorithm //STL 通用算法 #include bitset //STL 位集容器 #include cctype #include cerrno #include clocale #include cmath #include complex //复数类 #include cstdio #include cstdlib #include cstring #include ctime #include deque //STL 双端队列容器 #include exception //异常处理类 #include fstream #include functional //STL 定义运算函数(代替运算符) #include limits #include list //STL 线性列表容器 #include map //STL 映射容器 #include iomanip #include ios //基本输入/输出支持 #include iosfwd //输入/输出系统使用的前置声明 #include iostream #include istream //基本输入流 #include ostream //基本输出流 #include queue //STL 队列容器 #include set //STL 集合容器 #include sstream //基于字符串的流 #include stack //STL 堆栈容器 #include stdexcept //标准异常类 #include streambuf //底层输入/输出支持 #include string //字符串类 #include utility //STL 通用模板类 #include vector //STL 动态数组容器 #include cwchar #include cwctype using namespace std; /***********************************************************************/ C99 增加 #include complex.h //复数处理 #include fenv.h //浮点环境 #include inttypes.h //整数格式转换 #include stdbool.h //布尔环境 #include stdint.h //整型环境 #include tgmath.h //通用类型数学宏 /***********************************************************************/

math.h

数学函数库,一些数学计算的公式的具体实现是放在math.h里,具体有: 1 三角函数 double sin (double); double cos (double); double tan (double); 2 反三角函数 double asin (double); 结果介于[-PI/2, PI/2] double acos (double); 结果介于[0, PI] double atan (double); 反正切(主值), 结果介于[-PI/2, PI/2] double atan2 (double, double); 反正切(整圆值), 结果介于[-PI/2, PI/2] 3 双曲三角函数 double sinh (double); double cosh (double); double tanh (double); 4 指数与对数 double exp (double); double sqrt (double); double log (double); 以e为底的对数 double log10 (double); double pow(double x, double y)//计算以x为底数的y次幂 5 取整 double ceil (double); 取上整 double floor (double); 取下整 6 绝对值 double fabs (double); double cabs(struct complex znum) //求复数的绝对值 7 标准化浮点数 double frexp (double f, int *p); 标准化浮点数, f = x * 2^p, 已知f求x, p ( x介于[0.5, 1] ) double ldexp (double x, int p); 与frexp相反, 已知x, p求f 8 取整与取余 double modf (double, double*); 将参数的整数部分通过指针回传, 返回小数部分 double fmod (double, double); 返回两参数相除的余数 9其他 double hypot(double x, double y);//已知直角三角形两个直角边长度,求斜边长度 double ldexp(double x, int exponent);//计算x*(2的exponent次幂) double poly(double x, int degree, double coeffs [] )//计算多项式 nt matherr(struct exception *e)//数学错误计算处理程序 source: 《C C++ Code Capsules》

c语言中如何将 int转化为string 类型

可以使用以下方式:

1、使用循环,把每一位数字转换成相应的字符,参考代码如下:

#include stdio.h

#include string.h

int main()

{

int num, n, i = 0;

char str[20], tmp[20];

scanf("%d", num);

n = num % 10;

while (n0)

{

tmp[i++] = n + '0';

num = (num - n) / 10;

n = num % 10;

}

tmp[i] = '';

for (i=0; i=strlen(tmp)-1; i++)

{

str[i] = tmp[strlen(tmp)-i-1];

}

str[i] = '';

printf("%sn", str);

return 0;

}

2、使用库函数,代码如下:

#include stdio.h

#include string.h

int main()

{

int num;

char str[20];

scanf("%d", num);

itoa(num, str, 10);

printf("%sn", str);

return 0;

}

c语言设计中,为什么在头文件前加一个#呢

C语言中的 #

C#读成C Sharp

# 本身为指令 没有其他意义/也没有其他效果

# 号必须是该行除了任何空白字符外的第一个字符。预处理指令就是以#号开头的代码行。

# 后是指令关键字,在关键字和#号之间允许存在任意个数的空白字符。

整行语句构成了一条预处理指令,该指令将在编译器进行编译之前对源代码做某些转换。

下面举例说明下:

#define 标识符 字符串.

其中的“#”表示这是一条预处理命令。凡是以“#”开头的均为预处理命令.。

#,##(C++)

# 和 ## 操作符是和#define宏使用的. 使用# 使在#后的首个参数返回为一个带引号的字符串. 例如, 命令

#define to_string( s ) # s

将会使编译器把以下命令

cout to_string( Hello World! ) endl;

理解为

cout "Hello World!" endl;

使用##连结##前后的内容. 例如, 命令

#define concatenate( x, y ) x ## y

...

int xy = 10;

...

将会使编译器把

cout concatenate( x, y ) endl;

解释为

cout xy endl;

理所当然,将会在标准输出处显示'10'.

Pascal中的#

#m表示ascii码为m的字符,如#48表示‘0’,#65为‘A’,#13为回车。

可以在#后加$表示16进制的m,如#$30就是#48

呵呵,取了一个巧,复制的一个网页上的内容,当讲得十分全面,易理解。最初我也是看着才明白的....

c++怎样把double转为string

在Windows系统下的转换方法

windows下进行此类一般使用sprintf_s函数,使用该函数需要包含头文件stdio.h。

示例:例如我要将 1.234567 这个小数转化为字符串"1.234567“。首先,要包含头文件 cstdio(即 stdio.h)。

接着,要定义一个字符缓冲区 buffer,大小要足以容纳要转换的 double 变量。

再使用sprinf_s进行转换,转换的字符串保存在buffer中。

这时,就可以用string类型变量str来接收值了。

为了验证结果,我们加句代码输出这个str的值,程序运行的结果如下图。

c语言中何时引用#include

当使用到string.h中的函数时,需要引用头文件string.h

string.h为C语言库函数头文件之一,包含了内存处理及字符串处理函数。

1 内存处理相关函数,包括memcmp, memcpy, memset等。

2 字符串处理函数,包括strcpy, strcmp, strlen,strstr等。

当用到相关函数时,推荐引用string.h。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。