Message from C, C++ discussions
December 2019
— Well next to your name - Code warrior. Or what is this?
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
— 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
— 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):
https://godbolt.org/z/9QzUj-
— Looks like C as not using std::string
— You never know...
— True
— You forgot thread_local
😂