Message from C, C++ discussions

December 2019

— I created a function "mulstr" that need to multiplay the string many times as wanted by the argument here is the function:

char* mulstr(char* str, int multi){
char* multipled;
for(int i = 2; i <= multi; i++){
strcat(multipled, str);
return multipled;

and i got into a error segmention fault and i do not know why

Message permanent page


Prolly because you are using strcat which is accessing memory its not allowed to access and resulting in segfault

— So what do i need to do to get this function to work

— /

— For one the char* doesnt have a defined size and they are also read only. Try using dynamic memory allocation with malloc so you have better ability to manipulate the output

Message permanent page

— C or C++?

— I have a question regarding synchronization. I want to make yet another productor-consumer program (wrapped in a class), but I think I keep getting a deadlock and can't really find where I'm wrong (there surely is some lack of understanding):

Message permanent page

— Looks like C as not using std::string

— You never know...

— True

— You forgot thread_local😂

— Just add urs and make sure it compiles