Talk:ANSI C standard library

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

How does the glibc relate to this library? --HJH

glibc is GNU's implementation of the library. I think it contains extensions for the susv3 standard, but I haven't checked. -- Gregory Pietsch User:Gpietsch


The list was moved from the article

<assert.h>[edit]

for enforcing assertions when functions execute

void assert(int expression);

<ctype.h>[edit]

for classifying characters

int isalnum(int c);
int isalpha(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);

<errno.h>[edit]

for testing error codes reported by library functions

<float.h>[edit]

for testing floating-point type properties

FLT_RADIX
FLT_ROUNDS
FLT_DIG
FLT_EPSILON
FLT_MANT_DIG
FLT_MAX
FLT_MAX_EXP
FLT_MIN
FLT_MIN_EXP
DBL_DIG
DBL_EPSILON
DBL_MANT_DIG
DBL_MAX
DBL_MAX_EXP
DBL_MIN
DBL_MIN_EXP

<iso646.h>[edit]

for programming in ISO 646 variant character sets

<limits.h>[edit]

for testing integer type properties

CHAR_BIT
CHAR_MAX
CHAR_MIN
INT_MAX
INT_MIN
LONG_MAX
LONG_MIN
SCHAR_MAX
SCHAR_MIN
SHRT_MAX
SHRT_MIN
UCHAR_MAX
UCHAR_MIN
UINT_MAX
ULONG_MAX
USHRT_MAX

<locale.h>[edit]

for adapting to different cultural conventions

<math.h>[edit]

for computing common mathematical functions

double sin(double x);
double cos(double x);
double tan(double x);
double asin(double x);
double acos(double x);
double atan(double x);
double atan2(double y, double x);
double sinh(double x);
double cosh(double x);
double tanh(double x);
double exp(double x);
double log(double x);
double log10(double x);
double pow(double x, double y);
double sqrt(double x);
double ceil(double x);
double floor(double x);
double fabs(double x);
double ldexp(double x, int n);
double frexp(double x, int* exp);
double modf(double x, double* ip);
double fmod(double x, double y);

<setjmp.h>[edit]

for executing nonlocal goto statements

int setjmp(jmp_buf env);
void longjmp(jmp_buf env, int val);

<signal.h>[edit]

for controlling various exceptional conditions

SIGABRT
SIGFPE
SIGILL
SIGINT
SIGSEGV
SIGTERM
void (*signal(int sig, void (*handler)(int)))(int);
int raise(int sig);


<stdarg.h>[edit]

for accessing a varying number of arguments

void va_start(va_list ap, lastarg);
type va_arg(va_list ap, type);
void va_end(va_list ap);

<stddef.h>[edit]

for defining several useful types and macros


<stdio.h>[edit]

for performing input and output

FILE
stdin
stdout
stderr
FILENAME_MAX
FOPEN_MAX
TMP_MAX
FILE* fopen(const char* filename, const char* mode);
FILE* freopen(const char* filename, const char* mode, FILE* stream);
int fflush(FILE* stream);
int fclose(FILE* stream);
int remove(const char* filename);
int rename(const char* oldname, const char* newname);
FILE* tmpfile();
char* tmpname(char s[L_tmpnam]);
int setvbuf(FILE* stream, char* buf, int mode, size_t size);
void setbuf(FILE* stream, char* buf);
int fprintf(FILE* stream, const char* format, ...);
int printf(const char* format, ...);
int sprintf(char* s, const char* format, ...);
int vfprintf(FILE* stream, const char* format, va_list arg);
int vprintf(const char* format, va_list arg);
int vsprintf(char* s, const char* format, va_list arg);
int fscanf(FILE* stream, const char* format, ...);
int scanf(const char* format, ...);
int sscanf(char* s, const char* format, ...);
int fgetc(FILE* stream);
char* fgets(char* s, int n, FILE* stream);
int fputc(int c, FILE* stream);
char* fputs(const char* s, FILE* stream);
int getc(FILE* stream);
int getchar();
char* gets(char* s);
int putc(int c, FILE* stream);
int putchar(int c);
int puts(const char* s);
int unget(int c, FILE* stream);
size_t fread(void* ptr, size_t size, size_t nobj, FILE* stream);
size_t fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream);
int fseek(FILE* stream, long offset, int origin);
long ftell(FILE* stream);
void rewind(FILE* stream);
int fgetpos(FILE* stream, fpos_t* ptr);
int fsetpos(FILE* stream, const fpos_t* ptr);
void clearerr(FILE* stream);
int feof(FILE* stream);
int ferror(FILE* stream);
void perror(const char* s);

<stdlib.h>[edit]

for performing a variety of operations

double atof(const char* s);
int atoi(const char* s);
long atol(const char* s);
double strtod(const char* s, char** endp);
long strtol(const char* s, char** endp, int base);
unsigned long strtoul(const char* s, char** endp, int base);
int rand();
void srand(unsigned int seed);
void* calloc(size_t nobj, size_t size);
void* malloc(size_t size);
void* realloc(void* p, size_t size);
void free(void* p);
void abort();
void exit(int status);
int atexit(void (*fcm)(void));
int system(const char* s);
char* getenv(const char* name);
void* bsearch(const void* key, const void* base, size_t n, size_t size, int (*cmp)(const void* keyval, const void* datum));
void qsort(void* base, size_t n, size_t size, int (*cmp)(const void*, const void*));
int abs(int n);
long labs(long n);
div_t div(int num, int denom);
ldiv_t ldiv(long num, long denom);

<string.h>[edit]

for manipulating several kinds of strings

char* strcpy(char* s, const char* ct);
char* strncpy(char* s, const char* ct, int n);
char* strcat(char* s, const char* ct);
char* strncat(char* s, const char* ct, int n);
int strcmp(const char* cs, const char* ct);
int strncmp(const char* cs, const char* ct, int n);
char* strchr(const char* cs, int c);
char* strrchr(const char* cs, int c);
size_t strspn(const char* cs, const char* ct);
size_t strcspn(const char* cs, const char* ct);
char* strpbrk(const char* cs, const char* ct);
char* strstr(const char* cs, const char* ct);
size_t strlen(const char* cs);
char* strerror(int n);
char* strtok(char* s, const char* t);
void* memcpy(void* s, const void* ct, int n);
void* memmove(void* s, const void* ct, int n);
int memcmp(const void* cs, const void* ct, int n);
void* memchr(const char* cs, int c, int n);
void* memset(char* s, int c, int n);

<time.h>[edit]

for converting between various time and date formats

clock_t
CLOCKS_PER_SEC
time_t
struct tm
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
clock_t clock();
time_t time(time_t* tp);
double difftime(time_t time2, time_t time1);
time_t mktime(struct tm* tp);
char* asctime(const struct tm* tp);
char* ctime(const time_t* tp);
struct tm* gmtime(const time_t* tp);
struct tm* localtime(const time_t* tp);
size_t strftime(char* s, size_t smax, const char* fmt, const struct tm* tp);

<wchar.h>[edit]

for manipulating wide streams and several kinds of strings


<wctype.h>[edit]

for classifying wide characters

Wikipedia is not a programming guide. Some external link is good enough. -- Taku 05:01, Oct 29, 2003 (UTC)

No, Taku, I think it's alright to list the head files there, since I find that's useful for me. You can check out C programming language, there are a lot of "programming guide" there, including Data declaration, Control structures etc., if that's okay, there isn't anything wrong with the list here. --FallingInLoveWithPitoc 05:33, 29 Oct 2003 (UTC)
You know, maybe Wiki is a programming guide - so far you're the only one who keeps saying it isn't. Until there is a consensus/mandate/framework on which to base these edits, I suggest you take a break. Personally, I tend to agree with you, I don't think the headers have a place here, it's too much excruciating detail that does not help or enhance the article. However, let's come to an agreement with other programming contributors and work from there. Once we decide what WP is and isn't we'll be able to make progress. GRAHAMUK 05:38, 29 Oct 2003 (UTC)
Why haven't a place here? Someone come to check out this article, hoping to know the standard library, but there isn't any! Head files are quite necessary to be listed here, while the detalis of every head file(the functions) are under consideration. Anyway, I think those who checking out this article would like to get to know "what on earth are the standard libraires". Only a definition is far from satisfaction.--FallingInLoveWithPitoc 06:15, 29 Oct 2003 (UTC)
So, let me get this right - you come to Wikipedia looking for some authoritative technical resources. I dread to think what your programming efforts end up like. Like most of them, probably. Taku is right (and I like to play devil's advocate ;-) this is most likely NOT a programming guide. This will tell you what something is, but like any encyclopedia only in enough detail that you go away knowing a bit more than you did before, and maybe knowing where to look for further details. Short version - look up the headers in a proper book on the subject! GRAHAMUK 06:33, 29 Oct 2003 (UTC)
Why not put this in something like C library headers? Dysprosia 06:19, 29 Oct 2003 (UTC)
This is stated policy: Wikipedia is not "mere collections of public domain or other source material." Find an external link with the same material. -- Minesweeper 06:36, Oct 29, 2003 (UTC)
Then I think the article C programming language should be rewritten. There is no need for "Anatomy of a C Program" since this is not a "guide"? I think it's alright to list the head files like:
  • <assert.h>
  • <ctype.h>
  • <errno.h>...
"look up the headers in a proper book on the subject!"-- that's true, but it also needs to list what that "headers" are. I think "This will tell you what something is" also stand for that. --FallingInLoveWithPitoc 08:49, 29 Oct 2003 (UTC)

Sorry I didn't realize the discussion here is going on. I see maybe I am one of very few or only one person who claim wikipedia is not a programming guide. But I think it is part of mission statement of wikipedia. Wikipedia is an encyclopedia and regardless of if my opinions are minor or not, there is just no way to turn wikipedia into a programming guide. I understand sometimes I am destroying works made by someone else. My edits might make the articles useless. I am what is use if you see "c standard library provides standard functionalities for C programming." If you are C programming, such sentence is useless and the practical list is far useful. The only problem is that wikipedia is an encyclopedia so you know encyclopedia is often boring after all for those who already know the field. -- Taku 23:40, Nov 15, 2003 (UTC)

I think it is useful and relevant to list each header file and describe what it does, for example wchar.h above. But there is no need to list all of the functions and prototypes in each file, like time.h does. That can (and should) be in an external link. -- Merphant 00:09, 16 Nov 2003 (UTC)

It think It is more reasonable to discuss such along with discussing C programming language or its standard library. unistd.h for instance is not included the list above because ANSI C doesn't specify it. We should spend more about criticism of ANSI C standard just like as done to other programming languages. I think it is not off-topic in wikipedia to have each header file had its own article. Such article can have contents like what functions are included in ANSI C or what library supports it. I removed the list but it is not completely because we should provide only summary but because it is rather distracting to this article. In short, I think it would be a better way to provide such a list but I still don't see a reason to turn this article into an anatomy of header files. We don't need to replicate the specification here. -- Taku 01:31, Nov 16, 2003 (UTC)
I renew my opinion, it's okay to put that in talk page, which is often the solution for wikipedia to contain something looks like irrevelant. People can still look for info in the talk page. :) but i think an index of headers in the article would be better (no need to creat seperate pages to specify seperate header files). but anyway, who cares... --FallingInLoveWithPitoc 03:42, 16 Nov 2003 (UTC)

I've restored and expanded the description of the details of the facilities provided by this library and removed the suggestion that it should be moved to the C library article. There's too much useful material about just this one C library to include in the C library article, without even considering the range of other libraries for the C language. Knowing just how low level and critical to the C language these functions are is significant when compared to something like C++ or other languages. Taku, please have a look at Wikipedia:Editing_policy and what it says about large deletions and discussing them. Your edit is effectively a move to reduce the depth of coverage here, part of the long-running inclusionist/deletionist disagreement, with the deletionists having a "small/shallow wikipedia" model and the inclusionists a "large/deep wikipedia" model. JamesDay 13:33, 17 Nov 2003 (UTC)

I got rid of the prototypes, but left the descriptions, like I suggested above. I also included an external link which describes each header file in detail. -- Merphant 13:45, 17 Nov 2003 (UTC)

No, you don't get my idea. I didn't say that we should not discuss at all how C is low level using what a standard library provides. What I say is that it is off-topic to this article. The article itself is quite off-topic indeed. Why don't we have a C standard library while there is just a specific type of C library? It is like you have an article of Apple Pascal but not Pascal in general. I am a rather inclustionist. I think even each C function deserves its own article eventually. I mean why each particle of physics has its own article? If you have no idea about the atomic structure of molecules, it really doesn't make sense to discuss electrons or alpha particles. We don't have to resort to a programming guide but there is a way to show how very elementary functions are used and affect the entire program. What I am up to is refactoring, restructuring, if it may look destructive in some points. Anyway, I am going to have a C standard library article to discuss headers and standard functions in depth. -- Taku 18:52, Nov 17, 2003 (UTC)

I just created a C standard library article. I think you can see what I am trying to mean and what I am not trying to delete materials that might be considered too detailed. -- Taku 19:11, Nov 17, 2003 (UTC)