Ok, so I am working at a program that operates with sets. Each set has a name and an array for its elements. The user inputs for example "Alpha: 1 2 3 4 5", where Alpha is the name. I have to parse the string so that I get what's before the : symbol. It works perfectly with name declared as static (such as char name[10]), but when I am allocating memory for exactly as many characters as there are before the : , then I get either errors, either "Press any key to continue"... I used strncpy and also a function implemented by myself, but to no use.

Does anyone have another idea for implementing this? Thank you.