src/temp_out.c
/*
**	This function will write the contents of the temporary array to a file.
*/
This function will write the contents of the temporary array to a file.
This function will write the contents of the temporary array to a file .
_Bool	write_file(char *filename)
{
	int				fd;
	unsigned int	i;
	t_header		*header;
	fd = open(filename, O_CREAT | O_WRONLY, 0644);
	if (fd == -1)
		out_error(filename);
	header = generate_header(COREWAR_EXEC_MAGIC, g_prog_name, g_cursor_out,
		g_prog_comment);
	write(fd, header, sizeof(t_header));
	ft_memdel((void **)&header);
	i = 0;
	while (i < g_cursor_out)
		write(fd, g_temp_out + i++, 1);
	ft_putstr("Name:    \"");
	ft_putstr(g_prog_name);
	ft_putstr("\"\nComment: \"");
	ft_putstr(g_prog_comment);
	ft_putstr("\"\n\"");
	ft_putstr(g_filename_out);
	ft_putendl("\" successfully assembled!");
	return (1);
}
_Bool write_file ( char * filename ) { int fd ; unsigned int i ; t_header * header ; fd = open ( filename , O_CREAT | O_WRONLY , 0644 ) ; if ( fd == -1 ) out_error ( filename ) ; header = generate_header ( COREWAR_EXEC_MAGIC , g_prog_name , g_cursor_out , g_prog_comment ) ; write ( fd , header , sizeof ( t_header ) ) ; ft_memdel ( ( void * * ) & header ) ; i = 0 ; while ( i < g_cursor_out ) write ( fd , g_temp_out + i ++ , 1 ) ; ft_putstr ( " \" " ) ; ft_putstr ( g_prog_name ) ; ft_putstr ( " \" \n \" " ) ; ft_putstr ( g_prog_comment ) ; ft_putstr ( " \" \n \" " ) ; ft_putstr ( g_filename_out ) ; ft_putendl ( " \" " ) ; return ( 1 ) ; }
This function will write the contents of the temporary array to a file.
This function will write the contents of the temporary array to a file .