Partial preview of the text
Download Introduction to Calculus Programming on Lecture notes | CMSC 106 and more Study notes Computer Science in PDF only on Docsity!
Assorted string library function descriptions Input and output char* fgets(char *s,int sizc,iostream s) Reads characters into s until a newline character is seen or the end of the input is detected or until size characters have been read and adds a null character tos. Returns the NULL pointer value if there was no input to be read, otherwise returns a pointer to the first element of s. int puts(const char *s) Writes all characters in the string s before its terminating null character, and writes a newline char: rafter the last character of s print int strlen(const char *s) Returns the number of characters in s, not including its terminating null character. char* strnepy(char *s1, const char *s2, int n) Copies at most n characters of 82 into sl, adding null characters if s2 has fewer than n characters. Searching char* strstr(const char *s1, const char *s2) Returns a pointer lo the first occurrence of 82 if found in sl, or the NULL pointer value otherwise. char* strchr(const char *s, int ¢) Returns a pointer to the first occurrence of ¢ if found in sl, or the NULL pointer value otherwise. char* strrchr(const char *s, int c) Returns a pointer to the last occurrence of ¢ if found in sl, or the NULL pointer value otherwi int stremp(const char *s1, const char *s2) Compares s1 to s2 returning 0 if their characters are equal, a negative value if sl is less than $2, and a positive value otherwise. "Less than” refers to dictionary order. int strncmp(const char *s1, const char *s2, int n) Compares the first n characters only of s1 and s2 ,returning 0 if these parts of the strings are equal, a negative valuc if the first n characters of sl are less than $2, and a positive value otherwise, Joining .... char* strnceat(char *sl, const char *s2, int n) Appcnds at most n characters of s2 to sl, re- placing the null ch: first element of s1 eter at the end of sl with s2’s first character. Returns a pointer to the A few character library functions int isalpha(int c) Determines if ¢ is an uppercase or lowercase letter. int isupper(int c) Determines if ¢ is an uppercase or lowercase letter. int islower(int c)} Determines if ¢ is an uppercase or lowercase letter. int isspace(int c) Determines if ¢ is a whitespace chare int ispunct(int c) Determines if ¢ is a punctuation character. int isdigit(int c) Determines if c¢ is a digil character. int tolower(int c) Returns the lowercase equivalent of ¢ if ¢ was an uppercase character. int toupper(int c} Returns the uppercase equivalent of ¢ if c was an lowercase character.