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
Post a Comment