Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:25:36+00:00 2026-06-14T17:25:36+00:00

I use an external library to deal with udp (OSC) communication between 2 apps.

  • 0

I use an external library to deal with udp (OSC) communication between 2 apps.
To format the messages that will be sent, the library is expecting a char* but I get a string from the UI that I have to convert.

While I was dealing with other parts of my code the udp part was hard coded like that :

    char* endofMess = "from setEndMess"; 

and was working fine. I thought it would be easy to get it working with my strings and wrote :

    std::string s = "from setEndMess";
    char* endofMess = const_cast<char*>(s.c_str());

but unlike for the first example where I was receiving the message correctly formatted, I now receive only gibberish characters. Does somebody know where it can come from?

Thanks!

Matthieu

EDIT : the code I use :
The method to send the message each time OSCVal will change :

void osc500::testOSC(int identifier, float OSCval)
{
UdpTransmitSocket transmitSocket( IpEndpointName( destIP, port ) );
 char buffer[1024];
 osc::OutboundPacketStream p( buffer, 1024 );

p << osc::BeginBundleImmediate
    << osc::BeginMessage( endofMess )
       << OSCval << osc::EndMessage
<< osc::EndBundle;


transmitSocket.Send( p.Data(), p.Size() );
}

And if I have to change the OSC pattern I call this one :

void osc500::setEndMess(String endpattern){
// endofMess = "from setEndMess"; //OK works fine each time it's called

//1st try :
//std::string s = "from setEndMess"; 
//endofMess = const_cast<char*>(s.c_str()); //gibberish    

//2nd try :
//std::string s = "from setEndMess";
//endofMess = &s[0]; //gibberish    

//3rd & 4th tries :
//char s[4] = {'t','e','s','t'}; 
//char s[5] = {'t','e','s','t','\0'};
//endofMess = s; //gibberish    
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:25:37+00:00Added an answer on June 14, 2026 at 5:25 pm

    I suspect the char* is not written to, it is only non const because it is a legacy API. If so, your problem is probably that the std::string has fallen out of scope or been modified between the point where you call c_str and where it is used in the guts of the API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a main project that depends on other Library projects that use external JARS
I have a Qt project and would like to use an external library that
The question says it all, I am trying to use an external library in
I'm trying to use an external REST Library for my application, and I'm hoping
I have a library of common functions that I use in several different projects,
I'm trying to use an external library (wingraph) in a simple program. I have
I use MySQL extensively, but it doesn't support database-level encryption without some external library.
I have a WPF application and I use external library for generating documents. This
I have setup my project in SVN to use an external library. When I
When I use external library like Spring.Net, NUnit, NLog and etc. I don't see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.