Hi tasosmi,
I’m glad I could help. On the other hand, looking back at my code, I realized that the string buffer is too small! You need enough space to accommodate the whole AT command, not just the resulted ASCII number (of up to 5 chars (if eepin € [10000, 65535]) plus a null). I edited my code and made the buffer 20 chars long ‘cause I didn’t feel like counting the chars.
Now I don’t know in detail how your system is built up and works, but in my previous experience, I had to send carriage return (CR = ‘\r’) and line feed (LF = ’\n’) after every command, for it to be accepted.
You might want to consider that in your code and write "AT+CPIN=%04u\r\n", in the sprintf, if needed (of course, your buffer needs to accommodate 2 extra chars).
Arthur