Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 691167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:30:43+00:00 2026-05-14T02:30:43+00:00

string temp is equal to ZERO:\t.WORD\t1 from my debugger. (the first line of my

  • 0

string temp is equal to “ZERO:\t.WORD\t1” from my debugger. (the first line of my file)

string temp = RemoveWhiteSpace(data);
int i = 0;
if ( temp.length() > 0 && isalpha(temp[0]) )
    cout << "without true worked" << endl;
if ( temp.length() > 0 && isalpha(temp[0]) == true )
    cout << "with true worked" << endl;

This is my code to check if first character of temp is a a-z,A-Z. The first if statement will evaluate to true and the 2nd to false. WHY?!?!?! I have tried this even without the “temp.length() > 0 &&” and it still evaluates false. It just hates the “== true”. The only thing I can think of is that isalpha() returns != 0 and true == 1. Then, you could get isalpha() == 2 != 1. But, I have no idea if C++ is that … weird.

BTW, I dont need to know that the “== true” is logically pointless. I know.

output was

without true worked

Compiled with CodeBlock using GNU GCC on Ubuntu 9.10 (if this matters any)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:30:43+00:00Added an answer on May 14, 2026 at 2:30 am

    The is* functions are only guaranteed to return a non-zero value if true, NOT necessarily a 1. A typical implementation is table based, with one entry in the table for each character value, and a set of bits defining which bit means what. The is* function will just AND the right bitmask with the table value, and return that, which will only be the value 1 for whichever type happens to have been given bit position 0.

    E.g.:

    #define __digit 1
    #define __lower 2
    #define __upper 4
    extern int __type_table[];
    
    int isdigit(int c) { 
        return __type_table[c+1] & __digit;
    }
    
    int isalpha(int c) { 
        return __type_table[c+1] & (__lower | __upper);
    }
    
    int islower(int c) { 
        return __type_table[c+1] & __lower;
    }
    
    int isupper(int c) { 
        return __type_table[c+1] & __upper;
    }
    

    Where __type_table is defined as something like int __type_table[UINT_MAX+1]; and would be initialized so (for example) __type_table['0'+1] == __digit and __type_table['A'+1] == __upper.

    In case you care, the ‘+1’ part is to leave a spot at the beginning of the table for EOF (which is typically defined as -1).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

string popUpHTML=; var xx = from Temp in TemplateList where ( Temp.TitleID == titleID
I'm trying to split() a line of text and numbers from a .txt file.
I want to compare the first alphabet(string) of a file in a given directory
string fileName = test.zip; string path = c:\\temp\\; string fullPath = path + fileName;
I have code like this: string uriString = @C:\Temp\test.html; Uri uri = new Uri(uriString);
String[] a = c.toArray(new String[0]); First: Do I need type cast here? (I think
I'm trying to create a binary file from a intelHex file. Iside the intelHex
public override Models.CalculationNode Parse(string expression) { var calNode = new Models.CalculationNode(); int i =
I have a string, root?param1=...&param2=...&param3=... , and I want to create a java method
private static String readPasswordFile(String masterPassFilePath) throws Exception { File masterPassFile = new File(masterPassFilePath); if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.