runtime_error's blog

By runtime_error, 11 years ago, In English

many contestant in CF use std::string which i more easy than old c style string. but many experiensed programmers use old style string . what do you think which is better .please comment about their advantages and disadventages.

Tags c++
  • Vote: I like it
  • -18
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it -9 Vote: I do not like it

»
11 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Just personal tastes. std::string is little more convenient.

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Usually char array (C style) used, when its needed to read, write big text fast.

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

does anyone know how to read a string from input using scanf and put it in "std::string" variable?

  • »
    »
    11 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Read in char* buffer, then std::string s = buff.

    • »
      »
      »
      11 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I want direct way , I want to use std::string to avoid the char

      • »
        »
        »
        »
        11 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        scanf() is C function, it does not know C++ class string. The only way to read C++ string is to say where to write data, but it is unsafe. So, there is no direct way.