A string p is a prefix of a string s if the leading characters of s are identical to p. For example, "abc" is a prefix of "abcde". Develop a function prefix that checks if a C string p is a prefix of another C string s.
p
s
"abc"
"abcde"
prefix
p是s的前綴若s開頭的一段字串等於p。例如,"abc"是"abcde"的前綴。寫一個程式 判斷字串p是否字串s的前綴。
Example input 1:
abc abcde
Example output 1:
abc is a prefix of abcde
Example input 2:
bc abcde
Example output 2:
bc is not a prefix of abcde
Hidden content!#include <stdio.h>#include <stdlib.h>#include <string.h>int isprefix(char prefix[], char txt[]){ ** * * * * ** * * * i,flag=1;* * * * ** **** ** ** ** * * * **** ** *** *** * * ** *** * * ** * * * * * * ** * ** * **** *** * * ** *