How to put a string inside a char* variable in c++ -


well i'm going brief here. have variable:

char* string;

and function:

void addstring(char str[]) {  } 

and need add str string @ end of example: if string = "abc" , str = "123" after function addstring string = "abc123" searched on web, couldn't find need, help?

in c++, use std::string rather c-style character arrays:

#include <string>  std::string string; void addstring(std::string str) {     string += str; } 

if want steam, you'll need allocate large enough array result, copy strings in, , remember put terminator (zero-valued character) after end. c library functions strlen, strcpy , strcat might useful. details left exercise, since question c++ not c.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -