文本文件访问

FILE *fp;
fp=fopen(m_file_name, "a");
if(fp==NULL)
{
	PRINT_ERROR;
	return;
}
int temp_result;
temp_result=fwrite(m_msg_buffer, data_len, 1, fp);
fclose(fp);		
void print(const char *fmt, ...)
{
	if(m_output_en)
	{
		int data_len=0, temp_len;
		data_len+=GetTimeString(m_msg_buffer);
		data_len+=sprintf(m_msg_buffer+data_len, ", ");
		va_list args;
		va_start(args, fmt);
		temp_len=vsprintf(m_msg_buffer+data_len, fmt, args);
		if(temp_len<0)
		{
			PRINT_ERROR;
			return;
		}
		data_len+=temp_len;
		data_len+=sprintf(m_msg_buffer+data_len, "\n");

		if(!VcaFileExist(m_file_name))
		{
			VcaCreateFilePath(m_file_name);
		}
		FILE *fp;
		fp=fopen(m_file_name, "a");
		if(fp==NULL)
		{
			PRINT_ERROR;
			return;
		}
		int temp_result;
		temp_result=fwrite(m_msg_buffer, data_len, 1, fp);
		fclose(fp);		
	}
}

 

你可能感兴趣的:(C++)