Can someone who me an example on how to allocate memory in C++? I know I should be using new instead of malloc because i'm coding in C++ but I haven't found any simple examples anywhere..
Why i'm asking is because I need to create a function that searches through a string and removes a word that matches one if it finds it in the string.. I know in C I would do something like this..
int rem_word_func(char *data) {
int SzLen = strlen(data);
char buffer;
buffer=(char *)malloc(SzLen+1);
int count;
for(count=0;count<=SzLen;count++) {
if (buffer[count] == 32) ...
}
.....
return 0;
}
The reason why I need to allocate memory like that is because the size of the data in (char *data) .. can be any size, and I need to be able to copy it to another char and search through it using a loop..