fwrite isnґt working
#1

Hi. I made this command:
Код:
dcmd_8889(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
		new year, month, day, hour, minute, second;
		getdate(year, month, day);
		gettime(hour, minute, second);
		new string[256], fname[11];
		format(string, sizeof(string), "\n%d/%d/%d %d:%d:%d - %s: %s", year, month, day, hour, minute, second, Nick(playerid), params);
		format(fname, sizeof(fname), "FK/8889.txt");
		new File:file8889 = fopen(fname, io_write);
		fwrite(file8889, string);
		fclose(file8889);
	}
    return 1;
}
And I donґt get any errors, file 8889.txt is created, but nothing is written in it. What is that caused by? Thanks.

P.S. I tested it on Windows localhost, but I donґt think itґs matter.
Reply
#2

A better title: "My code isn't working", as fwrite work perfectly.

fname is not big enough for what you fill in it..it need one more cell, for the null character at the end, also you do not need format as you do not format anything, just do #define fname "FK/8889.txt", or new fname[] = "FK/8889.txt";
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)