C语言中的库函数定义在啥地方啊?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C语言中的库函数定义在啥地方啊?相关的知识,希望对你有一定的参考价值。

比如说我想知道"string.h"中的strcmp()函数具体是怎么实现的,那我应该到哪儿找啊??我用的是Visual Studio 6.0。。。

先顶一下楼上的,厉害~~~~~~~~~~
这对代码没有一个有用的。其实在头文件中只有函数的声明而没有函数的定义。这个头文件是给程序员看的,好让你知道有这些函数。那真正的函数定义在那呢?其实库文件中的函数早就已经编译好了存在.obj或者是.lib的文件里面。这种是静态的连接模式。在你的程序便已完成以后连接器再将你的程序的.obj文件和库文件进行连接最后生成.exe文件。如果你想看库文件的定义的话只能去网上自己找找啦。不过我个人感觉没有这个必要。其实大部分的库文件都是能够自己编写的。像strcmp()这种微软的库文件是更不可能放出原码的,不过可以去msdn里面碰碰运气。最后祝你好运啦。
参考技术A D:\Microsoft Visual C++ 6\VC98\INCLUDE\string.h

/***
*string.h - declarations for string manipulation functions
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file contains the function declarations for the string
* manipulation functions.
* [ANSI/System V]
*
* [Public]
*
****/

#if _MSC_VER > 1000
#pragma once
#endif

#ifndef _INC_STRING
#define _INC_STRING

#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif

#ifdef __cplusplus
extern "C"
#endif

/* Define _CRTIMP */

#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */

/* Define __cdecl for non-Microsoft compilers */

#if ( !defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif

/* Define _CRTAPI1 (for compatibility with the NT SDK) */

#ifndef _CRTAPI1
#if _MSC_VER >= 800 && _M_IX86 >= 300
#define _CRTAPI1 __cdecl
#else
#define _CRTAPI1
#endif
#endif

#ifndef _SIZE_T_DEFINED
typedef unsigned int size_t;
#define _SIZE_T_DEFINED
#endif

#ifndef _MAC
#ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif
#endif /* ndef _MAC */

#ifndef _NLSCMP_DEFINED
#define _NLSCMPERROR 2147483647 /* currently == INT_MAX */
#define _NLSCMP_DEFINED
#endif

/* Define NULL pointer value */

#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif

/* Function prototypes */

#ifdef _M_MRX000
_CRTIMP void * __cdecl memcpy(void *, const void *, size_t);
_CRTIMP int __cdecl memcmp(const void *, const void *, size_t);
_CRTIMP void * __cdecl memset(void *, int, size_t);
_CRTIMP char * __cdecl _strset(char *, int);
_CRTIMP char * __cdecl strcpy(char *, const char *);
_CRTIMP char * __cdecl strcat(char *, const char *);
_CRTIMP int __cdecl strcmp(const char *, const char *);
_CRTIMP size_t __cdecl strlen(const char *);
#else
void * __cdecl memcpy(void *, const void *, size_t);
int __cdecl memcmp(const void *, const void *, size_t);
void * __cdecl memset(void *, int, size_t);
char * __cdecl _strset(char *, int);
char * __cdecl strcpy(char *, const char *);
char * __cdecl strcat(char *, const char *);
int __cdecl strcmp(const char *, const char *);
size_t __cdecl strlen(const char *);
#endif
_CRTIMP void * __cdecl _memccpy(void *, const void *, int, unsigned int);
_CRTIMP void * __cdecl memchr(const void *, int, size_t);
_CRTIMP int __cdecl _memicmp(const void *, const void *, unsigned int);

#ifdef _M_ALPHA
/* memmove is available as an intrinsic in the Alpha compiler */
void * __cdecl memmove(void *, const void *, size_t);
#else
_CRTIMP void * __cdecl memmove(void *, const void *, size_t);
#endif

_CRTIMP char * __cdecl strchr(const char *, int);
_CRTIMP int __cdecl _strcmpi(const char *, const char *);
_CRTIMP int __cdecl _stricmp(const char *, const char *);
_CRTIMP int __cdecl strcoll(const char *, const char *);
_CRTIMP int __cdecl _stricoll(const char *, const char *);
_CRTIMP int __cdecl _strncoll(const char *, const char *, size_t);
_CRTIMP int __cdecl _strnicoll(const char *, const char *, size_t);
_CRTIMP size_t __cdecl strcspn(const char *, const char *);
_CRTIMP char * __cdecl _strdup(const char *);
_CRTIMP char * __cdecl _strerror(const char *);
_CRTIMP char * __cdecl strerror(int);
_CRTIMP char * __cdecl _strlwr(char *);
_CRTIMP char * __cdecl strncat(char *, const char *, size_t);
_CRTIMP int __cdecl strncmp(const char *, const char *, size_t);
_CRTIMP int __cdecl _strnicmp(const char *, const char *, size_t);
_CRTIMP char * __cdecl strncpy(char *, const char *, size_t);
_CRTIMP char * __cdecl _strnset(char *, int, size_t);
_CRTIMP char * __cdecl strpbrk(const char *, const char *);
_CRTIMP char * __cdecl strrchr(const char *, int);
_CRTIMP char * __cdecl _strrev(char *);
_CRTIMP size_t __cdecl strspn(const char *, const char *);
_CRTIMP char * __cdecl strstr(const char *, const char *);
_CRTIMP char * __cdecl strtok(char *, const char *);
_CRTIMP char * __cdecl _strupr(char *);
_CRTIMP size_t __cdecl strxfrm (char *, const char *, size_t);

#ifdef _MAC
unsigned char * __cdecl _c2pstr(char *);
char * __cdecl _p2cstr(unsigned char *);

#if !__STDC__
__inline unsigned char * __cdecl c2pstr(char *sz) return _c2pstr(sz);;
__inline char * __cdecl p2cstr(unsigned char *sz) return _p2cstr(sz);;
#endif
#endif

#if !__STDC__

/* prototypes for oldnames.lib functions */
_CRTIMP void * __cdecl memccpy(void *, const void *, int, unsigned int);
_CRTIMP int __cdecl memicmp(const void *, const void *, unsigned int);
_CRTIMP int __cdecl strcmpi(const char *, const char *);
_CRTIMP int __cdecl stricmp(const char *, const char *);
_CRTIMP char * __cdecl strdup(const char *);
_CRTIMP char * __cdecl strlwr(char *);
_CRTIMP int __cdecl strnicmp(const char *, const char *, size_t);
_CRTIMP char * __cdecl strnset(char *, int, size_t);
_CRTIMP char * __cdecl strrev(char *);
char * __cdecl strset(char *, int);
_CRTIMP char * __cdecl strupr(char *);

#endif /* !__STDC__ */

#ifndef _MAC
#ifndef _WSTRING_DEFINED

/* wide function prototypes, also declared in wchar.h */

_CRTIMP wchar_t * __cdecl wcscat(wchar_t *, const wchar_t *);
_CRTIMP wchar_t * __cdecl wcschr(const wchar_t *, wchar_t);
_CRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *);
_CRTIMP wchar_t * __cdecl wcscpy(wchar_t *, const wchar_t *);
_CRTIMP size_t __cdecl wcscspn(const wchar_t *, const wchar_t *);
_CRTIMP size_t __cdecl wcslen(const wchar_t *);
_CRTIMP wchar_t * __cdecl wcsncat(wchar_t *, const wchar_t *, size_t);
_CRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t);
_CRTIMP wchar_t * __cdecl wcsncpy(wchar_t *, const wchar_t *, size_t);
_CRTIMP wchar_t * __cdecl wcspbrk(const wchar_t *, const wchar_t *);
_CRTIMP wchar_t * __cdecl wcsrchr(const wchar_t *, wchar_t);
_CRTIMP size_t __cdecl wcsspn(const wchar_t *, const wchar_t *);
_CRTIMP wchar_t * __cdecl wcsstr(const wchar_t *, const wchar_t *);
_CRTIMP wchar_t * __cdecl wcstok(wchar_t *, const wchar_t *);

_CRTIMP wchar_t * __cdecl _wcsdup(const wchar_t *);
_CRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *);
_CRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t);
_CRTIMP wchar_t * __cdecl _wcsnset(wchar_t *, wchar_t, size_t);
_CRTIMP wchar_t * __cdecl _wcsrev(wchar_t *);
_CRTIMP wchar_t * __cdecl _wcsset(wchar_t *, wchar_t);

_CRTIMP wchar_t * __cdecl _wcslwr(wchar_t *);
_CRTIMP wchar_t * __cdecl _wcsupr(wchar_t *);
_CRTIMP size_t __cdecl wcsxfrm(wchar_t *, const wchar_t *, size_t);
_CRTIMP int __cdecl wcscoll(const wchar_t *, const wchar_t *);
_CRTIMP int __cdecl _wcsicoll(const wchar_t *, const wchar_t *);
_CRTIMP int __cdecl _wcsncoll(const wchar_t *, const wchar_t *, size_t);
_CRTIMP int __cdecl _wcsnicoll(const wchar_t *, const wchar_t *, size_t);

#if !__STDC__

/* old names */
#define wcswcs wcsstr

/* prototypes for oldnames.lib functions */
_CRTIMP wchar_t * __cdecl wcsdup(const wchar_t *);
_CRTIMP int __cdecl wcsicmp(const wchar_t *, const wchar_t *);
_CRTIMP int __cdecl wcsnicmp(const wchar_t *, const wchar_t *, size_t);
_CRTIMP wchar_t * __cdecl wcsnset(wchar_t *, wchar_t, size_t);
_CRTIMP wchar_t * __cdecl wcsrev(wchar_t *);
_CRTIMP wchar_t * __cdecl wcsset(wchar_t *, wchar_t);
_CRTIMP wchar_t * __cdecl wcslwr(wchar_t *);
_CRTIMP wchar_t * __cdecl wcsupr(wchar_t *);
_CRTIMP int __cdecl wcsicoll(const wchar_t *, const wchar_t *);

#endif /* !__STDC__ */

#define _WSTRING_DEFINED
#endif

#endif /* ndef _MAC */

#ifdef __cplusplus

#endif

#endif /* _INC_STRING */
参考技术B 你找lib这个目录,当然lib这个目录在很多的目录下都有.就象windows里的program
files这个目录在c盘下有,在d盘下也可以存在.不过red
hat在你装完系统后就会在几个地方创建了lib这个目录,这个目录下面的都是库文件.lib是libraray的简写,翻译成"库",说白了就是图书馆贝!注意登陆lib这个目录时,你可能只能用超级用户才能登陆上去,然后才能看.超级用户帐号默认是:root;注意用户名和密码都是这个
参考技术C strcmp()函数具体是怎么实现的??
我可以告诉你,这个具体实现的代码,你是看不到的,因为MS已经把它做成lib了,至于你要看头文件,上面的这位已经都贴出来了。

在C语言里标准函数存放在啥文件中?

拜托了
兄弟们,我是菜鸟!简单点就好

    C语言标准库函数存放在头文件当中,使用相应函数时需要用include引用先关头文件。

    C语言程序设计里,C 标准函数(C Standard library)是所有目前符合标准的头文件(head
    file)的集合,以及常用的函数库实现程序,例如 I/O输入输出和字串符控制。不像 COBOL、Forrian和 PL/I等编程语言,在 C
    语言的工作任务里不会包含嵌入的关键字,所以几乎所有的 C 语言程序都是由标准函数库的函数来创建的。

    下面列出C89及C99中C语言标准函数库的头文件。

      C89中标准的头文件
      <assert.h> 设定断言点
      <ctype.h> 字符处理
      <errno.h> 错误报告
      <float.h> 定义与实现相关的浮点值勤
      <limits.h> 定义与实现相关的各种极限值
      <locale.h> 支持函数setlocale()
      <math.h> 数学函数库使用的各种定义
      <setjmp.h> 支持非局部跳转
      <signal.h> 定义信号值
      <stdarg.h> 支持可变长度的变元列表
      <stddef.h> 定义常用常数
      <stdio.h> 支持文件输入和输出
      <stdlib.h> 其他各种声明
      <string.h> 支持串函数
      <time.h> 支持系统时间函数
      C99新增的头文件和库
      <complex.h> 支持复数算法
      <fenv.h> 给出对浮点状态标记和浮点环境的其他方面的访问
      <inttypes.h> 定义标准的、可移植的整型类型集合。也支持处理最大宽度整数的函数
      <iso646.h> 首先在此1995年第一次修订时引进,用于定义对应各种运算符的宏
      <stdbool.h> 支持布尔数据类型类型。定义宏bool,以便兼容于C++
      <stdint.h> 定义标准的、可移植的整型类型集合。该文件包含在<inttypes.h>中
      <tgmath.h> 定义一般类型的浮点宏
      <wchar.h> 首先在1995年第一次修订时引进,用于支持多字节和宽字节函数
      <wctype.h> 首先在1995年第一次修订时引进,用于支持多字节和宽字节分类函数

参考技术A C系统提供了丰富的系统文件,称为库文件,C的库文件分为两类,一类是扩展名为".h"的文件,称为头文件,在前面的包含命令中我们已多次使用过。在".h"文件中包含了常量定义、 类型定义、宏定义、函数原型以及各种编译选择设置等信息。另一类是函数库,包括了各种函数的目标代码,供用户在程序中调用。 通常在程序中调用一个库函数时,要在调用之前包含该函数原型所在的".h" 文件。
下面给出Turbo C的全部".h"文件。
Turbo C头文件
 ALLOC.H 说明内存管理函数(分配、释放等)。
 ASSERT.H 定义 assert调试宏。
 BIOS.H 说明调用IBM—PC ROM BIOS子程序的各个函数。
 CONIO.H 说明调用DOS控制台I/O子程序的各个函数。
 CTYPE.H 包含有关字符分类及转换的名类信息(如 isalpha和toascii等)。
 DIR.H 包含有关目录和路径的结构、宏定义和函数。
 DOS.H 定义和说明MSDOS和8086调用的一些常量和函数。
 ERRON.H 定义错误代码的助记符。
 FCNTL.H 定义在与open库子程序连接时的符号常量。
 FLOAT.H 包含有关浮点运算的一些参数和函数。
 GRAPHICS.H 说明有关图形功能的各个函数,图形错误代码的常量定义,正对不同驱动程序的各种颜色值,及函数用到的一些特殊结构。
 IO.H 包含低级I/O子程序的结构和说明。
 LIMIT.H 包含各环境参数、编译时间限制、数的范围等信息。
 MATH.H 说明数学运算函数,还定了 HUGE VAL 宏, 说明了matherr和matherr子程序用到的特殊结构。
 MEM.H 说明一些内存操作函数(其中大多数也在STRING.H中说明)。
 PROCESS.H 说明进程管理的各个函数,spawn…和EXEC …函数的结构说明。
 SETJMP.H 定义longjmp和setjmp函数用到的jmp buf类型,说明这两个函数。
 SHARE.H 定义文件共享函数的参数。
 SIGNAL.H 定义SIG[ZZ(Z] [ZZ)]IGN和SIG[ZZ(Z] [ZZ)]DFL常量,说明rajse和signal两个函数。
 STDARG.H 定义读函数参数表的宏。(如vprintf,vscarf函数)。
 STDDEF.H 定义一些公共数据类型和宏。
 STDIO.H 定义Kernighan和Ritchie在Unix System V 中定义的标准和扩展的类型和宏。还定义标准I/O 预定义流:stdin,stdout和stderr,说明 I/O流子程序。
 STDLIB.H 说明一些常用的子程序:转换子程序、搜索/ 排序子程序等。
 STRING.H 说明一些串操作和内存操作函数。
 SYS\STAT.H 定义在打开和创建文件时用到的一些符号常量。
 SYS\TYPES.H 说明ftime函数和timeb结构。
 SYS\TIME.H 定义时间的类型time[ZZ(Z] [ZZ)]t。
 TIME.H 定义时间转换子程序asctime、localtime和gmtime的结构,ctime、 difftime、 gmtime、 localtime和stime用到的类型,并提供这些函数的原型。
 VALUE.H 定义一些重要常量,包括依赖于机器硬件的和为与Unix System V相兼容而说明的一些常量,包括浮点和双精度值的范围。
参考技术B 在C语言处理系统中,标准库函数存放在不同的头文件(也称标题文件)中,例如输入、输出函数存放在"stdio.h"中,求绝对值和三角函数存放在"math.h"中 参考技术C BIOS.H。。。不是标准库

分两部分 一部分是.h文件 一部分是.lib文件本回答被提问者采纳

以上是关于C语言中的库函数定义在啥地方啊?的主要内容,如果未能解决你的问题,请参考以下文章

数组存放在啥位置?

有关C语言的内部函数和外部函数的定义说明

c 语言是不是需要头文件和库函数

在C语言中要怎样调用函数公式来进行编程啊?

C 语言定义

c语言中的extern是啥,有啥作用啊?