c++ - char* concatenation not working properly -


i ran issue wasn't able find solutin till now. have function should act string.concat in c#:

char* va(char* text, ...) {     char buffer[1000];     va_list parameters;     va_start(parameters, text);     vsprintf(buffer, text, parameters);     return buffer; } 

but reason if this:

for (int = 0; < 12; i++)     addoption(va("option %i", i)); 

the menu fields display "option 11", seems text overwriting. tried disableing "string pooling" in project settings, didn't change anything! appreciated!

you should use

char *buffer = new char[1000] 

for return of function char* va()need heap variable


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -