in C

FILE *fout;
fout=fopen("text.txt", "w+");
fputs(stringa, fout);