Message-ID: <2FFF738A.74A4@linetap.com> From: nebo Organization: neboland MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Writing to a file. References: <01bdaac9$dbe7ec80$bf0562cb AT default> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 43 Date: Thu, 09 Jul 1998 03:04:30 GMT NNTP-Posting-Host: 209.205.49.227 NNTP-Posting-Date: Wed, 08 Jul 1998 23:04:30 EDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Oliver Batchelor wrote: > > Hello, > I am writing a map editor for a game I am making A rts game with tiles. > I have a big array of tiles. > > eg. unsigned char map[100][100] > > I have done the editing part. All I need now is to save the array into a > file. > > Can anyone tell me how I would dump the array to a binary file ?? > > thanks, > > Oliver Batchelor FILE *map_file; map_file = fopen("FILE.DAT", "wb"); fwrite((char*) &map, sizeof(map), 1, map_file); fclose(map_file); //Will write sizeof(map) bytes to the given file map_file = fopen("FILE.DAT", "rb"); fread((char*)&map, sizeof(map), 1, map_file); fclose(map_file); //Will read sizeof(map) bytes from the file filling map[][] -- Nb nebo AT LTS MajorNet nebo AT linetap DOT com Internet I'll stop drinking when I can't pour, I'll stop standing when I fall over, I'll stop moving when I pass out, I'll stop dreaming when I die.