简体   繁体   中英

C++ SNAP Library convert std::string to TStr

In the SNAP Library there's a method that allows me to save a file in my pc here it is:

TSnap::SaveEdgeList(G, q, "Edge list format");`

in this function the 2nd argument its type is TStr which represents string types in SNAP library

I have a string variable that contains a full directory of where I want to put my file like this:

string filedir = openFileDialog1->FileName;

What I want to do is to give the content of a string variable to a TStr variable like this:

TStr q = filedir;

But unfortunately it gives an error. So i was wondering if anyone has an alternative solution or something Thank you

Quick googling revealed that TStr can be constructed from a C-string via TStr(const char* CStr) constructor.

So, following will work:

TStr q = filedir.c_str();

Alternatively, you can pass filedir.c_str() directly as an argument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM