How to check if string starts with certain string in C?

后端 未结 5 1569
遥遥无期
遥遥无期 2021-01-04 03:42

For example, to validate the valid Url, I\'d like to do the following

char usUrl[MAX] = \"http://www.stackoverflow\"

if(usUrl[0] == \'h\'
   && usUr         


        
5条回答
  •  既然无缘
    2021-01-04 04:15

    The following should check if usUrl starts with "http://":

    strstr(usUrl, "http://") == usUrl ;
    

提交回复
热议问题