I think you are correct about the sprintf. You are attempting to write to 'schoix', which is a char * . But for now, it's completely unitialized. What is this pointer pointing TO? There's no memory available for sprintf to write to. Add schoix = newchar [30]; before your sprintf, and that section will work :) note you have to eventually de-allocate, and you should account for buffer overflow, etc.