Trying to get the address of the address of the data in a {c}string

⚓ Rust    📅 2025-10-22    👤 surdeus    👁️ 3      

surdeus

I need to create a vector of *mut c_voids. Each one points to a function argument (i am using ffi crate).

Trying to work out how to deal with a cstring.

In c++ I would do

     std::vector<void*> v;
     std::string s = std::string("foo");
     const char* ps = s.c_str();
     v.push_back(static_cast<void*> (const_cast<char**>(&ps)));

I cant work out the rust equivalent

3 posts - 2 participants

Read full topic

🏷️ Rust_feed