| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1252 人关注过本帖, 1 人收藏
标题:C语言库函数 [一眼了然]
只看楼主 加入收藏
liyanhong
Rank: 3Rank: 3
来 自:水星
等 级:禁止访问
威 望:8
帖 子:1867
专家分:0
注 册:2008-5-3
收藏(1)
 问题点数:0 回复次数:5 
C语言库函数 [一眼了然]
PS:如果有一人顶此帖  我就多添加一条库函数范例   顶的人越多偶发的库函数越多



以字母顺序:
****************************************************************************
                                            abort()
****************************************************************************

Prototype: void abort(void);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: Similar to exit, it will return an exit code indicating an abnormal program exit to the operating system and quit the program.


//Example:
Example aborts the program
#include <cstdlib>
int main()
{
  abort();
}



****************************************************************************
                                           abs()
****************************************************************************
Prototype: int abs(int aNum);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: The abs function returns the absolute value of a number (makes it positive) as an integer.


//Example:
//Program asks for user input of an integer
//It will convert it to positive if it was negative
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
  int aNum;
  cout<<"Enter a positive or negative integer";
  cin>>aNum;
  cout<<abs(aNum);
}


****************************************************************************
                                   acos()
****************************************************************************

Prototype: double acos(double a_cos);
Header File: math.h (C) or cmath (C++)
Explanation: Acos is used to find the arccosine of a number (give it a cosine value and it will return the angle, in radians corresponding to that value). It must be passed an argument between -1 and 1.

//
Example gives the angle corresponding to cosine .5
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  cout<<acos(.5);
}


****************************************************************************
                                  asin()
****************************************************************************

Prototype: double asin(double a_sin);
Header File: math.h (C) or cmath (C++)
Explanation: Asin is used to find the arcsine of a number (give it a sin value and it will return the angle, in radians corresponding to that value). It must be passed an argument between -1 and 1.


//Example gives the angle corresponding to sine 1
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  cout<<asin(1);
}



****************************************************************************
                                atan()
****************************************************************************

Prototype: double atan(double a_tan);
Header File: math.h (C) or cmath (C++)
Explanation: Acos is used to find the arctangent of a number (give it a tangent value and it will return the angle, in radians corresponding to that value). It accepts all real numbers.

//
Example gives the angle corresponding to tangent 10
#include <iostream>
#include <cmath>
int main()
{
  cout<<atan(10);
}



****************************************************************************
                             atexit()  
****************************************************************************

Prototype: int atexit(void (_USERENTRY * func)(void));
Header File: stdlib.h (C) or cstdlib (C++)
ANSI: C and C++
Explanation: Use atexit to have a function called when the program exits. The parameter it accepts is a function name, without the typical () of a function call. It must return void and accept no values (hence the use of void in the prototype of atexit). If atexit is called more than once, the last function passed to it will be the first one executed. It can be used up to 32 times.


//
Example:
#include <iostream>
#include <cstdlib>

using namespace std;

//Program calls atexit with FinalFunction
//FinalFunction is executed before program ends
void FinalFunction(void)
{
    cout<<"Final function called";
}
int main()
{
  atexit(FinalFunction);
}


****************************************************************************
                           atof()
****************************************************************************

Prototype: float atof(const char *string);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: This function accepts a string and converts it into a floating point number. For example, if "1234.34" is passed into the function, it will return 1234.34. If the string contains a decimal place, the number will not be truncated. If a valid number is contained in the string, but is terminated by a non-valid character, the number will be returned, and the non-valid character will be ignored

//
Example reads in a string, and converts it to an float
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
  char a_char[10];
  cin>>a_char;
  cout<<"As a float: "<<atof(a_char);
}


//
const char *pContent; //*pContent是const, pContent可变
const (char *) pContent;//pContent是const,*pContent可变



****************************************************************************
                         atoi()
****************************************************************************
Prototype: int atoi(const char *string);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: This function accepts a string and converts it into an integer. For example, if "1234" is passed into the function, it will return 1234, an integer. If the string contains a decimal place, the number will be truncated. Eg, "104.21" will be returned as 104.

Example:
//Example reads in a string, and converts it to an integer
#include <cstdlib>
#include <iostream>
int main()
{
  char a_char[10];
  cin>>a_char;
  cout<<"As an integer: "<<atoi(a_char);
}


****************************************************************************
                       atol()
****************************************************************************

Prototype: long atol(const char *string);
Header File: cstdlib or (stdlib.h for C)
Explanation: This function accepts a string and converts it into a long. For example, if "1234" is passed into the function, it will return 1234. It is similar to atoi, except that it can handle larger numbers (up to the maximum size of a long). If the string contains a decimal place, the number will be truncated. Eg, "104.21" will be returned as 104.

Example:
//Example reads in a string, and converts it to a long
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
  char a_char[10];
  cin>>a_char;
  cout<<"As a long: "<<atol(a_char);
}


****************************************************************************
                         ceil()
****************************************************************************
Prototype: double ceil(double x);
Header File: math.h (C) or cmath (C++)
Explanation: Use this to round a number up. It returns the smallest integer greater than or equal to x.
ANSI: C and C++


//Program uses ceil to round a decimal number up.  
//Program also shows using ciel to round division up.
#include <cmath>
#include <iostream>
int main()
{
  cout<<ceil(2.0/4.0);
  double x=.4;
  cout<<ceil(x);
}

****************************************************************************
                      clock()
****************************************************************************
Prototype: clock_t clock(void);
Header File: time.h (C) or ctime (C++)
Explanation: This function returns the number of clock ticks (the CPU time taken) the program has taken. To convert to the number of seconds, divide by CLOCKS_PER_SEC, which is defined in time.h


Example:
//Example will run a loop, and then print the number of clock ticks and
//number of seconds used
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
    for(int x=0; x<1000; x++)
    {
        cout<<endl;
    }
    cout<<"Clock ticks: "<<clock()<<" Seconds: "<<clock()/CLOCKS_PER_SEC;
}



****************************************************************************
                       cosh()
****************************************************************************

Prototype: double cosh (double a);
Header File: math.h (C) or cmath (C++)
Explanation: Returns the hyperbolic cosine of a.

//Example prints the hyperbolic cosine of .5
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
    cout<<cosh(.5);
}


****************************************************************************
                     ctime()
****************************************************************************

Prototype: char *ctime(const time_t *time)
Header File: time.h (C) or ctime (C++)
ANSI: C and C++
Explanation: Use ctime to convert a time_t variable into a string of 26 characters in the format Fri Jan 28 09:12:21 2000\n\0 where \n and \0 are the newline and terminating null character. The string it returns will be overwritten unless you copy the string to another variable before calling ctime again.


Example:
//Program uses ctime to convert a time_t variable into a human readable
//string in form Fri Jan 28 00:00:00 2000\n\0

#include <ctime>
#include <iostream>

using namespace std;

int main()
{
  time_t hold_time;
  hold_time=time(NULL);
  cout<<"The date is: "<<ctime(&hold_time);
}



****************************************************************************
                           div()
****************************************************************************
Prototype: div_t div(int numerator, int denominator);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: Div takes a fraction (numerator/denominator) and places the quotient and the remainder into the struct it returns, div_t. In div_t the two ints are quot and rem, quotient and remainder.


#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    div_t answer;
    answer = div(76, 5);
        cout<<"As an improper fraction, 76/5";
    cout<<"As a proper fraction, "<<answer.quot<<" "<< answer.rem<<"/5";
}


****************************************************************************
                        exit()
****************************************************************************

Prototype: void exit(int ExitCode);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: Exit ends the program. The ExitCode is returned to the operating system, similar to returning a value to int main.
Example
//Program exits itself
//Note that the example would terminate anyway
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    cout<<"Program will exit";
    exit(1); // Returns 1 to the operating system

    cout<<"Never executed";
}


****************************************************************************
                        fabs()
****************************************************************************
Prototype: double fabs(double number);
Header File: math.h (C) or cmath (C++)
Explanation: This function returns the absolute value of a number. It will not truncate the decimal like abs() will, so it is better for certain calculations.
Example:
//Example outputs absolute value of -12.3 with fabs and abs
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
  cout<<"Abs(-12.3)="<<abs(-12.3)<<endl;
  cout<<"Fabs(-12.3)="<<fabs(-12.3);
}


****************************************************************************
                   floor()
****************************************************************************
Prototype: double floor(double Value);
Header File: cmath
Explanation: Returns the largest interger value smaller than or equal to Value. (Rounds down)

Example:
//Example will output 5.9 rounded down
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
  cout<<"5.9 rounded down: "<<floor(5.9);
}


****************************************************************************
                  getchar()
****************************************************************************

Prototype: int getchar(void);
Header File: stdio.h (C) or cstdio (C++)
Explanation: This function reads in a character. It returns the character as the ASCII value of that character. This function will wait for a key to be pressed before continuing with the program

Example:
//Example waits for a character input, then outputs the character
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
  char a_char;
  a_char=getchar();
  cout<<a_char;
}

****************************************************************************
                  getenv()
****************************************************************************
Prototype: char *getenv(const char *atypeofinformation);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: Getenv wll return a pointer to a string that contains system information pertaining to atypeofinformation. For example, path names, or devices. This is implementation-defined, so you might need to check your compiler manual.

// Example shows the currently defined paths (usually set in autoexec.bat)
// For *nix systems, simply replace PATH with an environment variable
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    cout<<getenv("PATH");  
}


****************************************************************************
                  isalnum()
****************************************************************************
Prototype: int isalnum(int ch);
Header File: ctype.h (C) cctype (C++)
Explanation: Isalnum does exactly what is sounds like, checks if the ASCII value passed in has a character equivalent to a number of letter. It returns non-zero for true, and zero for false.


//Example reads in a character and checks if it is alpha-numeric
#include <iostream>
#include <cctype>

using namespace std;

int main()
{
    char x;
    cin>>x;
    if(isalnum(x))
    {
        cout<<"It's alpha-numeric";
    }
    else
    {
        cout<<"It's not alpha-numeric";  
    }
}


****************************************************************************
                 isdigit()
****************************************************************************

Prototype: int isdigit(int Character);
Header File: ctype.h (C) or cctype (C++)
Explanation: This function accepts an ASCII value, and returns whether or not it is a digit (0 to 9) when converted to its equivalent ASCII character. It returns a zero if it is not a digit, and non-zero if it is.

//Example reads in a character and checks to see if it is a digit
#include <cctype>
#include <iostream>

using namespace std;

int main()
{
    char a_char;
    cin>>a_char;
    if(isdigit(a_char))
    {
        cout<<"Is a digit!";
    }
    else
    {
        cout<<"Is not a digit!";
    }
}

****************************************************************************
                isgraph()
****************************************************************************

Prototype: int isgraph(int Char);
Header File: ctype.h (C) or cctype (C++)
Explanation: Checks whether the character is printable, and returns true if it is with the exception of the space, which it will return false for.


Example:
//Example inputs a character
//Example checks if character can be printed
#include <cctype>
#include <iostream>

using namespace std;

int main()
{
    char x;
    cout<<"Enter any character: ";
    cin>>x;
    if(isgraph(x)
    {
        cout<<x;
    }
    else
    {
        cout<<"Sorry, could not print character";
    }
}



****************************************************************************
                                 ispunct()
****************************************************************************
Prototype: int ispunct (int c);
Header File: ctype.h (C) or cctype (C++)
Explanation: Tests if the ASCII character corresponding to the integer stored in c is a punctuation character.

#include &tl;iostream>
#include &tl;cctype>

using namespace std;

//Example reads in a character and tests if it punctuation
int main()
{
    char x;
    cin>>x;
    if(isspunct(x))
    {
        cout<<"Punctuation";
    }
    else
    {
        cout<<"Not punctuation.";
    }
}




****************************************************************************
                             isspace()
****************************************************************************


Prototype: int isspace(int ch);
Header File: ctype.h (C) or cctype (C++)
Explanation: Isspace does exactly what is sounds like, checks if the ASCII value passed in is that of a space key (such as tab, space, newline, etc). It returns non-zero for true, and zero for false.

//Example reads in a character and checks if it is a type of space
#include <iostream>
#include <cctype>

using namespace std;

int main()
{
    char x;
    cin>>x;
    if(isspace(x))
    {
        cout<<"It's a space";
    }
    else
    {
        cout<<"It's not a space;  
    }
}


****************************************************************************
                            isupper()
****************************************************************************
Prototype: int isupper (int c);
Header File: ctype.h (C) or cctype (C++)
Explanation: Tests to see if the ASCII character associated with the integer c is an uppercase letter

#include <iostream>
#include <cctype>

using namespace std;

//Example reads in a character and tests if it uppercase
int main()
{
    char x;
    cin>>x;
    if(isupper(x))
    {
        cout<<"Uppercase";
    }
    else
    {
        cout<<"Not uppercase.";
    }
}


****************************************************************************
                           kbhit()
****************************************************************************

Prototype: int kbhit(void);
Header File: conio.h
Explanation: This function is not defined as part of the ANSI C/C++ standard. It is generally used by Borland's family of compilers. It returns a non-zero integer if a key is in the keyboard buffer. It will not wait for a key to be pressed

Example:
//Example will loop until a key is pressed
//Example will not work with all compilers
#include <conio.h>
#include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        if(kbhit())
        {
            break;
        }
    }
}


****************************************************************************
                           log10()
****************************************************************************
Prototype: double log10(double anumber);
Header File: math.h (C) or cmath (C++)
Explanation: Log10 returns the logarithm for anumber, as long as it is not negative, or zero. To find the logarith of another base, use log base 10 of the number divided by log base 10 of the base to find the logarithm for.


//Example gives the log base ten of 100
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  cout<<log10(100);
}



****************************************************************************
                           log()
****************************************************************************

Prototype: double log(double anumber);
Header File: math.h (C) or cmath (C++)
Explanation: Log returns the natural logarithm for anumber, as long as it is not negative, or zero. .

//Example gives the natural logarithm of 100
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    cout<<log(100);
}



****************************************************************************
                        memcmp()   
****************************************************************************

Prototype: int memcmp(const void *buffer1, const void *buffer2, size_t count);
Header File: string.h (C) or cstring (C++)
Explanation: Alphabetically compares two arrays passed in to it. The fact that it is a void * simply means that it can have non-character arrays passed in to it. It is also necessary to pass how far to compare (ie, the size of the arrays) The return value is:
Less than zero      buffer1 is less than buffer2
Zero                buffer1 is equal to buffer2
Greater than zero   buffer1 is greater than buffer2  


Example:
//Program compares two character arrays
//Program compares only to eight letters
#include <cstring>
#include <iostream>

using namespace std;

int main()
{
    int comp_val=memcmp("Andersronc", "Zandimva",  8);
    if ( comp_val == 0 )
    {
        cout<<"strings are equal";
    }
    if ( comp_val<0 )
    {
        cout<<"String one is alphabetically small";
    }
    else
    {
        cout<<"String one is alphabetically greater";
    }
}





****************************************************************************
                       modf()
****************************************************************************
Prototype: double modf(double number, double *intpart);
Header File: math.h (C) or cmath (C++)
Explanation: This function will return the decimal part of number, and it will place the integer part of number into the variable pointed to by intpart.


Example:
//Example will output decimal and integer parts of 12.34
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
    double x;
    modf(12.34, &x);  
    cout<<"Decimal: "<<modf(12.34, &x)<<"Fractional: "<<x;
}


****************************************************************************
                       pow()
****************************************************************************

Prototype: double pow(double b, double p);
Header File: math.h (C) or cmath (C++)
Explanation: This function raises b to the p power.

Example:
//Example will computer 4 to the 5th
#include <cmath>
#include <iostream>
int main()
{
    cout<<"4 to the 5th power is: "<<pow(4, 5);
}


****************************************************************************
                       putchar()
****************************************************************************
Prototype: int putchar(int achar);
Header File: stdio.h (C) or cstdio (C++)
Explanation: Putchar writes the character corresponding to the ASCII value of achar to stdout, which is usually the monitor. It returns achar.
#include <cstdio>
#include <iostream>
using namespace std;

//Example outputs the character corresponding to the ASCII value 65
int main()
{
    putchar(65);
}


****************************************************************************
                      putenv()
****************************************************************************

Prototype: int putenv(const char *asetting);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: Use putenv to modify the environmental settings for the program. It should be used in the form: TYPE_OF_SETTING (such as PATH, DEVICE, etc.)=WHAT_TO_SET_TO.
//Example sets the defined paths for the program to C:\
//Example then lists the paths
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    putenv("PATH=C:\");
    cout<<getenv("PATH");  
}

****************************************************************************
                      puts()
****************************************************************************

Prototype: int puts(const char *astring);
Header File: stdio.h (C) or cstdio (C++)
Explanation: This function, puts, will output the string pointed to by astring. It will then add a newline character. This is built in to the function. It returns a nonnegative integer if it was successful. It returns EOF if there was an error.


//Example outputs "Hello, World" with a newline
#include <cstdio>

using namespace std;

int main()
{
    puts("Hello World");
}


****************************************************************************
                    rand()
****************************************************************************

Prototype: int rand();
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: rand returns a value between(inclusive) 0 and and RAND_MAX (defined by the compiler, often 32767). To get a more mangeale number, simply use the % operator, which returns the remainder of division.


Example:
//Program returns a random number
#include <iostream&rt;
#include <cstdlib&rt;

using namespace std;

int main()
{
    cout<<rand();
    cout<<rand()%6;  //Number between 0 and 5
}


****************************************************************************
                   remove()
****************************************************************************

Prototype: int remove(const char *filename);
Header File: stdio.h (C) or cstdio (C++)
Explanation: Remove will erase a file specified by filename. Upon success it will return zero, upon failure it will return nonzero.


Example:
//Example will erase useless.txt, in the current directory
//It is recommend that useless.txt be...useless
#include <cstdio>

using namespace std;

int main()
{
  if ( !remove("useless.txt") )
  {
      cout<<"Successful deletion";
  }
  else
  {
      cout<<"Oops, file not deleted (is it there?)";
  }
}


****************************************************************************
                   rename()
****************************************************************************

Prototype: int rename(const char *afilename, const char *newname);
Header File: stdio.h (C) or cstdio (C++)
Explanation: This function will rename a file of name afilename, to whatever is newname.

Example:
//Example requires example.txt to be in working directory
//Example renames example.txt to newname.txt
#include <cstdio>
int main()
{
    rename("example.txt", "newname.txt");
}


****************************************************************************
                  sinh()
****************************************************************************
Prototype: double sinh (double a);
Header File: cmath.h (C) or cmath (C++)
Explanation: Returns the hyperbolic sine of a.

//Example prints the hyperbolic sine of .5
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
  cout<<sinh(.5);
  return 0;
}



****************************************************************************
                       sqrt()
****************************************************************************
Prototype: double sqrt(double Value);
Header File: math.h (C) or cmath (C++)
Explanation: Returns the square root of Value. Probably not a good idea to try a negative number for Value...


Example:
//Example will give sqare root of numbers 1 to 10
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
    for(int x = 1; x < 11; x++)
    {
        cout<<"Square root of: "<<x<<" is "<<sqrt(x)<<endl;
    }
}


****************************************************************************
                       srand()
****************************************************************************
Prototype: void srand(unsigned int seed);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: Srand will seed the random number generator to prevent random numbers from being the same every time the program is executed and to allow more pseudorandomness.

Example:
//Program uses time function to seed random number generator
//and then generates random number
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
    srand((unsigned)time(NULL));
    int d=rand()%12;  
    cout<<d;
}


****************************************************************************
                      strcat()
****************************************************************************
Prototype: char *strcat(char *Destination, char *Source);
Header File: string.h (C) or cstring (C++)
Explanation: This function will concatenate (add to the end) the string pointed to by source on to the string pointed to by Destination. Returns a pointer to the Destination string.
Example:
//Example concatenates two strings to output
//By asking the user for input
#include <cstring>
#include <iostream>

using namespace std;

int main()
{
    char *s1 = new char[30];
    char *s2 = new char[30];
    cout<<"Enter string one(without spaces): ";
    cin>>s1;
    cout<<"Enter string two(without spaces): ";
    cin>>s2;
    cout<<strcat(s1, s2);
}



****************************************************************************
                     strcmp()
****************************************************************************

Prototype: int strcmp (const char *string1, const char *string2);
Header File: string.h (C) or cstring (C++)
Explanation: Tests the strings for equality. Returns a negative number if string1 is less than string2, returns zero if the two strings are equal, and returns a positive number is string1 is greater than string2
//Example reads in two strings (w/out spaces) and compares them for equality
#include <cstring>
#include <iostream>

using namespace std;

int main()
{
    char *str1=new char[20];
    char *str2=new char[20];
    cin>>str1;
    cin>>str2;
    if(!strcmp(str1, str2)
    {
        cout<<"Strings are equal!";
    }
}

****************************************************************************
                    strerror()
****************************************************************************
Prototype: char *strerror(int errnum);
Header File: string.h (C) or cstring (C++)
Explanation: Strerror returns a pointer to a string that contains the identification for an error-number. This is usually used with a function that returns an error number based on the result of an operation. It is a very bad idea to start modifying the string it returns.

//Example prints out error number 2
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    cout<<strerror(2);  
}

****************************************************************************
                   time()
****************************************************************************

Prototype: time_t time(time_t* timer);
Header File: time.h (C) or ctime (C++)
ANSI: C and C++
Explanation: Returns and sets the passed in variable to the number of seconds that have passed since 00:00:00 GMT January 1, 1970. If NULL is passed in, it will work as if it accepted nothing and return the same value.

Example:
//Program will use time_t to store number of seconds since 00:00:00 GMT
//Jan. 1, 1970
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
    time_t hold_time;
    hold_time=time(NULL);
    cout<<"The number of elapsed seconds since Jan. 1, 1970 is "<<hold_time;
}


****************************************************************************
                  tolower()
****************************************************************************

Prototype: int tolower(int chr);
Header File: ctype.h (C) or cctype (C++)
Explanation: Tolower will return the ASCII value for the lowercase equivalent of the ASCII character chr, if it is a letter. If the character is already lowercase, it remains lowercase

//Example reads in a character and makes up lowercase
#include <iostream>
#include <cctype>

using namespace std;

int main()
{
    char x;
    cin>>x;
    x=tolower(x);
    cout<<x;
}


****************************************************************************
                  toupper()
****************************************************************************

Prototype: int toupper(int aChar);
Header File: ctype.h (C) or cctype (C++)
Explanation: toupper accepts a character as an argument (it actually accepts an integer, but the two are interchangeable) and will convert it to uppercase, and will return the uppercase character, in the form of an ASCII integer, and leave the parameter unchanged.

Example:
//Program creates char d, sets it equal to lowercase letter
//Converts it to uppercase and outputs it
#include <cctype>
#include <iostream>

using namespace std;

int main()
{
    char d='a';  
    d=toupper(d);
    cout<<d;
}
收到的鲜花
  • zqy1100072008-11-20 12:46 送鲜花  2朵   附言:好东西!不过就是一点..都是英文的,感觉不爽 ...
搜索更多相关主题的帖子: C语言 函数 
2008-11-20 11:35
liyanhong
Rank: 3Rank: 3
来 自:水星
等 级:禁止访问
威 望:8
帖 子:1867
专家分:0
注 册:2008-5-3
收藏
得分:0 
被你猜中了   偶这两天在补习英语  就逛了几个英文网站  边复习边学习  偶聪明吧

看到好东西就整理下来 跟大家一起共享

爱上你 是 我的错  可是离 开  又舍不得  听着你为我写的歌     好难过
如果说 我说如果  我们还 能  重新来过   不去计 较 谁对谁错  会怎么做
2008-11-20 13:09
liyanhong
Rank: 3Rank: 3
来 自:水星
等 级:禁止访问
威 望:8
帖 子:1867
专家分:0
注 册:2008-5-3
收藏
得分:0 
//我晕哦  怎么没一个人顶  太意外了

爱上你 是 我的错  可是离 开  又舍不得  听着你为我写的歌     好难过
如果说 我说如果  我们还 能  重新来过   不去计 较 谁对谁错  会怎么做
2008-11-20 17:23
风居住的街道
Rank: 1
等 级:新手上路
帖 子:374
专家分:0
注 册:2008-10-24
收藏
得分:0 
因为man太好用了……
2008-11-20 17:40
Ethip
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:771
专家分:0
注 册:2008-1-18
收藏
得分:0 
赞个!
2008-11-20 20:38
侃大川
Rank: 2
等 级:论坛游民
威 望:1
帖 子:27
专家分:22
注 册:2009-11-12
收藏
得分:0 
赞个!
2010-06-09 15:18
快速回复:C语言库函数 [一眼了然]
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039557 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved