How can I check if a string has special characters in C++ effectively?

前端 未结 9 866
情话喂你
情话喂你 2021-02-08 13:15

I am trying to find if there is better way to check if the string has special characters. In my case, anything other than alphanumeric and a \'_\' is considered a special charac

9条回答
  •  难免孤独
    2021-02-08 13:44

    You can use something like this:

    #include 
    
    for(int i=0;i

    The isalpha() function checks whether it is alphanumeric or not and isdigit() checks whether it is digit.

提交回复
热议问题