Thursday, October 20, 2011

C/C++ programming functions

abs()
Int
Return absolute value
stdlib.h
acos()
Double
Return arc cosine
math.h
asin()
Double
Return arc sin
math.h
atan()
Double
Return arc tangent
math.h
atan2(d1,d2)
Double
Return arc tangent of d1/d2
math.h
atof()
Double
Convert string to double
stdlib.h
atoi()
Int
Convert string to integer
stdlib.h
atol()
Long
Convert string to long integer
stdlib.h
calloc(u1,u2)
Void
Return a pointer of the beginning allocate memory
malloc.h
stdlib.h
ceil()
Double
Return round up value
math.h
cos()
Double
Return cosign
math.h
cosh()
Double
Return the hyperbolic cosine
math.h
difftime(l1,l2
Double
Return time difference l1-l2
time.h
exit()
Void
Close all file & buffer & terminate the program
stdlib.h
exp()
Double
Return the exponential value
math.h
fabs()
Double
Return the absolute value
math.h
fclose(f)
Int
Close file & return 0 if successful
stdio.h
feof()
Int
Determine if an end-of file condition has been reached. If so, return non zero else 0
stdio.h
fgetc(f)
Int
Enter a single character from file f
stdio.h
fgets(s,i,f)
Char
Enter string s, containing I characters, from file f
stdio.h
floor()
Double
Return round down value
math.h
fmod(d1,d2)
Double
Return remainder of d1%d2
math.h
fopen(s1,s2)
File
Open a file name s1 of type s2. Return a pointer to the file
stdio.h
fprintf(f,…)
Int
Send data item to file f, (remaining arguments are complicated)
stdio.h
fputc(c,f)
Int
Send a single character to file
stdio.h
fputs(s,f)
Int
Send a string to file
stdio.h
fread(s,i1,i2,f)
Int
Enter i2 data items, each of size i1 bytes, from file f to string s
stdio.h
free(p)
Void
Free a block of allocate memory whose beginning is indicated by p
malloc.h
stdio.h
fscanf(f,…)
Int
Enter data item from the file f
stdio.h
fseek(f,l,i)
Int
Move the pointer for file f a distance l bytes from location i
stdio.h

ftell(f)

Long

Return the current pointer position within file f

stdio.h
fwrite(s,i1,i2,f)
Int
Enter i2 data items, each of size i1 bytes, from string s to file f
stdio.h
fetc(f)
Int
Enter a single character from file f
stdio.h
fetchar()
Int
Enter a single character from standard input device
stdio.h
gets()
Char
Enter a string  from keyboard
stdio.h
isalnum(c)
Int
Determine if argument is alphanumeric, return a non zero value if true else zero
ctype.h
isalpha(c)
Int
Determine if argument is alphabetic, return a non zero value if true else zero
ctype.h
isascii(c)
Int
Determine if argument is an ascii character, return a non zero value if true else zero
ctype.h
iscntrl(c)
Int
Determine if argument is ascii control character, return a non zero value if true else zero
ctype.h
isdigit(c)
Int
Determine if argument is a  decimal digit, return a non zero value if true else zero
ctype.h
isgraph(c)
Int
Determine if argument is a graphic ascii character, return a non zero value if true else zero
ctype.h
islower(c)
Int
Determine if argument is lowercase, return a non zero value if true else zero
ctype.h
issodigit(c)
Int
Determine if argument is an octal digit, return a non zero value if true else zero
ctype.h
isprint(c)
Int
Determine if argument is a printing ascii character, return a non zero value if true else zero
ctype.h
ispunct(c)
Int
Determine if argument is a punctuation character, return a non zero value if true else zero
ctype.h
isspace(c)
Int
Determine if argument is a white space character, return a non zero value if true else zero
ctype.h
isupper(c)

Int

Determine if argument is uppercase character, return a non zero value if true else zero

ctype.h
isxdigit(c)
Int
Determine if argument is a hexadecimal digit, return a non zero value if true else zero
ctype.h
labs(l)
Long
Return the absolute value
math.h
log(d)
Double
Return the natural logarithm
math.h
log10(d)
Double
Return the logarithm base 10 of d
math.h
malloc(u)
Void
Allocate u bytes of memory. Return a pointer to the beginning of the allocate space
malloc.h
stdlib.h
pow(d1,d2)
Double
Return the d1 raise to the d2 power
math.h
printf(…)
Int
Send data item to the  standard output device
stdio.h
putc(c,f)
Int
Send  a single character to file f
stdio.h
putchar(c)
Int
Send a single character to the  standard output device
stdio.h
puts(s)
Int
Send a string  to the  standard output device
stdio.h
rand()
Int
Return a random positive integer
stdlib.h
rewind(f)
Void
Move the pointer to the beginning of the file f
stdio.h
scanf(…)
Int
Input data item to the  standard input device
stdio.h
sin(d)
Double
Return the sine of d
math.h
sinh(d)
Double
Return the hyperbolic sine of d
math.h
sqrt(d)
Double
Return the square root  of d
math.h
srand()
Void
Initialize the random number generator
stdlib.h
strstr(s1,s2)
strcmp(s1,s2)

Int


Int

Search string s2 from s1

Compare two string lexicographically. Return a negative value if s1<s2, positive if s1>s2, zero if s1==s2

string.h

string.h
strcmpi(s1,s2)
Int
Compare two string lexicographically without regard to case. Return a negative value if s1<s2, positive if s1>s2, zero if s1==s2
string.h
strcpy(s1,s2)
Char
Copy string s2 to s1
string.h
strlen()
Int
Return the number of character in a string
string.h
strset(s,c)
Char
Set all character within s to c
string.h
strlwr(s)

Convert uppercase string to lowercase
string.h
strupr(s)

Convert lowercase string to uppercase
string.h
system(s)
Int
Pass command s to the operating system. Return 0 if the command is successfully executed else non-zero (-1)
stdlib.h
tan(d)
Double
Return the tangent value of d
math.h
tanh(d)
Double
Return the hyperbolic tangent value of d
math.h
time(p)
Long
Return the number of second elapsed beyond a designated base time
time.h
toascii(c)
Int
Convert value of argument to ascii
ctype.h
tolower(c)
Int
Convert upper to lowercase
ctype.h
toupper(c)
Int
Convert lowercase to upper
ctype.h








From: Me