About 115,000 results
Open links in new tab
  1. Ways of initialising a string in c++ - Stack Overflow

    Dec 15, 2015 · In the second, you declare an array of strings of undefined length (computed by compiler, based on how many objects you define in the initializer list) and you initialize one …

  2. C++ string initialization - Stack Overflow

    May 6, 2014 · For initialization of a variable definition using assignment, like. std::string a = "foo"; Here two objects are created: The variable you define (a in my example) and a temporary …

  3. c++ - How to initialize an std::string with a length? - Stack Overflow

    Dec 9, 2014 · std::string does not support lengths known at compile time. There's even a proposal for adding compile time strings to the C++ standard.

  4. How to initialize a string set in C++? - Stack Overflow

    @Antonio the passages referencing std there (lib.global.names, lib.reserved.name) govern standard library implementation compliance, not the naming of local variables in user code; …

  5. c++ - Initialising a std::string from a character - Stack Overflow

    Apr 12, 2010 · It occurred to me that since std::string AKA std::basic_string<char> accepts string literals which are char *s just as a char [] does, it can accept a char just like a char [] would. …

  6. c++ - initializing std::string from char* without copy - Stack Overflow

    Nov 30, 2016 · C++17 introduces another choice: std::string_view, which replaced std::string in many function signatures, is a non-owning reference to a character data. It is implicitly …

  7. c++ - How to initialize an std::string using ""? - Stack Overflow

    Mar 19, 2011 · I'm facing problems with initializing a std::string variable using "" (i.e. an empty string). It's causing strange behavior in code that was previously working. Is the following …

  8. c++ string array initialization - Stack Overflow

    Mar 9, 2012 · @rwst: Yes, today it is. Thanks. I probably used iterators to support common Visual C++ in 2012. The simple loop you show has a slight inefficiency in that it copies strings but (1) …

  9. How to declare an array of strings in C++? - Stack Overflow

    Jan 28, 2016 · Also, because of the way arrays are passed to functions (converted to a pointer to the first element), it doesn't work across function calls even if the signature looks like an array …

  10. c++ - Initializing strings as null vs. empty string - Stack Overflow

    Feb 5, 2015 · The default constructor initializes the string to the empty string. This is the more economic way of saying the same thing. However, the comparison to NULL stinks. That is an …

Refresh