C库函数 - sqrt()
C库函数 - sqrt() #include <stdio.h> #include <math.h> int main () { printf("Square root of %lf is %lf\n", 4.0, sqrt(4.0) ); printf("Square root of %lf is %lf\n", 5.0, sqrt(5.0) ); return(0); }
阅读全文 ↗C库函数 - sqrt() #include <stdio.h> #include <math.h> int main () { printf("Square root of %lf is %lf\n", 4.0, sqrt(4.0) ); printf("Square root of %lf is %lf\n", 5.0, sqrt(5.0) ); return(0); }
阅读全文 ↗C库函数 - pow() #include <stdio.h> #include <math.h> int main () { printf("Value 8.0 ^ 3 = %lf\n", pow(8.0, 3)); printf("Value 3.05 ^ 1.98 = %lf", pow(3.05, 1.98)); return(0); }
阅读全文 ↗C库函数 - modf() #include<stdio.h> #include<math.h> int main () { double x, fractpart, intpart; x = 8.123456; fractpart = modf(x, &intpart); printf("Integral part = %lf\n", intpart); printf("Fraction Part = %lf \n", fractpart); return(0); }
阅读全文 ↗C库函数 - ldexp() #include <stdio.h> #include <math.h> int main () { double x, ret; int n; x = 0.65; n = 3; ret = ldexp(x ,n); printf("%f * 2^%d = %f\n", x, n, ret); return(0); }
阅读全文 ↗C库函数 - frexp() #include <stdio.h> #include <math.h> int main () { double x = 1024, fraction; int e; fraction = frexp(x, &e); printf("x = %.2lf = %.2lf * 2^%d\n", x, fraction, e); return(0); }
阅读全文 ↗C库函数 - setlocale() #include <locale.h> #include <stdio.h> #include <time.h> int main () { time_t currtime; struct tm *timer; char buffer[80]; time( &currtime ); timer = localtime( &currtime ); printf("Locale is: %s\n", setlocale(LC_ALL, "en_GB")); strftime(buffer,80,"%c", timer ); printf("Date is: %s\n", buffer); printf("Locale is: %s\n", setlocale(LC_ALL, "de_DE")); strftime(buffer,80,"%c", timer ); printf("Date is: %s\n", buffer); return(0); }
阅读全文 ↗C库 - <limits.h> #include <stdio.h> #include <limits.h> int main() { printf("The number of bits in a byte %d\n", CHAR_BIT); printf("The minimum value of SIGNED CHAR = %d\n", SCHAR_MIN); printf("The maximum value of SIGNED CHAR = %d\n", SCHAR_MAX); printf("The maximum value of UNSIGNED CHAR = %d\n", UCHAR_MAX); printf("The minimum value of SHORT INT = %d\n", SHRT_MIN); printf("The maximum value of SHORT INT = %d\n", SHRT_MAX); printf("The minimum value of INT = %d\n", INT_MIN); printf("The maximum value of INT = %d\n", INT_MAX); printf("The minimum value of CHAR = %d\n", CHAR_MIN); printf("The maximum value of CHAR = %d\n", CHAR_MAX); printf("The minimum value of LONG = %ld\n", LONG_MIN); printf("The maximum value of LONG = %ld\n", LONG_MAX); return(0); }
阅读全文 ↗C库 - <float.h> #include <stdio.h> #include <float.h> int main () { printf("The maximum value of float = %.10e\n", FLT_MAX); printf("The minimum value of float = %.10e\n", FLT_MIN); printf("The number of digits in the number = %.10e\n", FLT_MANT_DIG); }
阅读全文 ↗C库宏 - errno #include <stdio.h> #include <errno.h> #include <string.h> extern int errno ; int main () { FILE *fp; fp = fopen("file.txt", "r"); if( fp == NULL ) { fprintf(stderr, "Value of errno: %d\n", errno); fprintf(stderr, "Error opening file: %s\n", strerror(errno)); } else { fclose(fp); } return(0); }
阅读全文 ↗C库函数 - toupper() #include <stdio.h> #include <ctype.h> int main () { int i = 0; char c; char str[] = "Tutorials Point"; while(str[i]) { putchar (toupper(str[i])); i++; } return(0); }
阅读全文 ↗C库函数 - tolower() #include <stdio.h> #include <ctype.h> int main () { int i = 0; char c; char str[] = "TUTORIALS POINT"; while( str[i] ) { putchar(tolower(str[i])); i++; } return(0); }
阅读全文 ↗C库函数 - isxdigit() #include <stdio.h> #include <ctype.h> int main () { char var1[] = "tuts"; char var2[] = "0xE"; if( isxdigit(var1[0]) ) { printf("var1 = |%s| is hexadecimal character\n", var1 ); } else { printf("var1 = |%s| is not hexadecimal character\n", var1 ); } if( isxdigit(var2[0] )) { printf("var2 = |%s| is hexadecimal character\n", var2 ); } else { printf("var2 = |%s| is not hexadecimal character\n", var2 ); } return(0); }
阅读全文 ↗