About 66,400 results
Open links in new tab
  1. Detecting balanced parentheses - Code Review Stack Exchange

    Feb 19, 2024 · This should also speed up the check c in closing. We can check to see if the set of keys and the set of values are disjoint by using opening.isdisjoint(closing) (see the next section …

  2. c - Simple method to detect int overflow - Code Review Stack Exchange

    Dec 12, 2013 · To detect int overflow/underflow in C, I use this code. What might be a simpler and more portable way of coding this (that is, fewer conditions)? Assume 2's complement and don't use wider …

  3. C function to read only numeric values - Code Review Stack Exchange

    Jul 24, 2023 · I'm learning C and as exercise I'm trying to implement a custom function to parse a input from user and return successfully only if the input is a number. These are my files, how could I …

  4. Check for null/empty in dictionary - Code Review Stack Exchange

    It is always going to return a string. But why do you even check for string.IsNullOrEmpty()? You already know it isn't null from the previous line's check -- queryWhere["account"] != null -- so at worst it is …

  5. c - Input validation - Code Review Stack Exchange

    May 10, 2021 · I believe your (a == 1) check is redundant, since it is in the 2nd part of an || expression. (This comment is redundant, given @Reinderein's reply below, but I include it for completeness.) …

  6. Checking if each char in a string is a decimal digit

    May 5, 2017 · In the cctype header, you have the std::isdigit(int) function. You can use this instead of your conditions that check if the character is between '0' and '9'. You index into a std::string with an …

  7. Directory write permissions check - Code Review Stack Exchange

    <untrusted> Set directory to "c:\Windows\System32\" </untrusted> Write something into a file contained in directory. In this particular case, since directory is a non-ref parameter, it is not possible for …

  8. Check for balanced parentheses - Code Review Stack Exchange

    Oct 23, 2014 · I was given an assignment to check for balanced parentheses from an arbitrary string where parentheses are defined as (, [ or { and their respective "closing" parentheses. The other …

  9. c++ - Validation/error handling of user input values - Code Review ...

    This is a tiny learning program that lead to an interesting question: how can I best/most elegantly handle user entered numbers? This method works, fails cleanly, and reads well. It doesn't apply to

  10. contains() algorithm for std::vector - Code Review Stack Exchange

    Aug 10, 2014 · template <class T> bool contains(std::vector<T> const &v, T const &x) { return ! (v.empty() || std::find(v.begin(), v.end(), x) == v.end()); } As far as more efficient goes, there are a …