What are the differences between the strlen() and sizeof() a char* string pointer in C? Why?
Write the function
replace(char base[], char from[], char to[])
which finds the string 'from' in the string 'base' and replaces it with the string 'to'. You may assume that from and to are the same length. For example, the code
char string[] = "recieve";
replace(string, "ie", "ei");
//> should change 'string' to "receive".
Be careful not to assume the substring being replaced is singular, or that its own substrings are unique.
Do not rescan letters already checked/replaced
char string[] = "Msissisippi";
replace(string, "sis", "iss");
//> should change 'string' to "Mississippi" (.. and not miss the second "sis")
char string[] = " flajellate";
replace(string, "laj", "lag");
//> should change 'string' to "flagellate" (.. and not modify "lat")
Are strlen() and sizeof() of the two string variables below different? (run the code to test your assumption - be sure to load < string.h> to get access to strlen())
Why is strlen() the same or different?
Why is sizeof() the same or different?
char* string0 = "hello";
char string1[] = "hello";