Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.

I need help in C Programming?

I am writing an if condition

it is if(value is not an alphabetic character){

do something

regards

}

I dont know any efficient way of doing it. I can do that but it will be so long

if(value!='a'||value!='b'...............value!='z')

{body}

Does anyone know how to write a condition to exclude all alphabetic characters

3 Antworten

Relevanz
  • Anonym
    vor 1 Jahrzehnt
    Beste Antwort

    This will do it.

    if (!(((value >= 'a') && (value < = 'z')) ||

    ((value >= 'A') && (value < = 'Z'))))

  • vor 1 Jahrzehnt

    The best way to do this is:

    if ( ! isalpha ( value ) )

    isalpha is the ISO standard function from ctypes.h that tells you whether the character is alphabetic.

    You can write a test like ('a'<=value && value<='z') || ('A'<=value && value<='Z') but that is of limited use and shouldn't make it into commercial software. It's fine in Italy for Italian words, but anywhere like the UK or USA where there is the occassional use of accented or non-Roman letters it fails (e.g. Beyoncé with an é at the end).

  • vor 1 Jahrzehnt

    yeah dude..:)

    * you can get the value as an integer datatype and check it whether the inputted data ranges from ASCII code of alphabets(i.e., from A to Z and from a to z)

    check it out..:):)

Haben Sie noch Fragen? Jetzt beantworten lassen.