CS 24000 Lecture Notes - Lecture 4: C Dynamic Memory Allocation, Substring, C String Handling
Document Summary
Cs240 lecture 4 notes 01242017 functions and main. String functions in c: c provides string fucntions such as, stry(char *dest, char *src) Copy string src to dest: int strlen(char *s) Return the length of a string: char *strcat(char *dest, char *src) Concatenates string src after string dest. dest should point to a string large enough to have both dest and src and the null terminator: int strcmp(char *a, char *b) Compares to strings a, b. returns >0 is a is larger alphabetically that b, <0 if b is larger than a, or 0 if a and b are equal. String functions in c: char *strstr(const char *haystack, const char *needle), find the first occurrence of the substring needle in the string haystack, returning a pointer to the fund substring. Char strdup(const chars): return a duplicate of the string s in memory allocated using malloc.