Nope, that's the way to do it, directly initializing the vector with the data from the string.
As @ildjarn points out in his comment, if for whatever reason your data buffer needs to be null-terminated, you need to explicitly add it with charvect.push_back('')
.
Also note, if you want to reuse the buffer, use the assign
member function which takes iterators.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…