missed part of what you were trying to do. Sorry.. I saw the "^M" and figured that was part of your complaint.
yeah, closing the file before finishing the loop would definitely stop it from writing anymore though. :) - Valnir ----- Original Message ----- From: "Mervine, Keith" <[EMAIL PROTECTED]> To: "Valnir" <[EMAIL PROTECTED]>; <[email protected]> Sent: Wednesday, August 04, 2004 9:49 AM Subject: RE: Output to file Nope, all it did was remove the extra line. Now all I'm getting is 2 0 0 Just checked something now it works....oh for the misplacement of a } void mobstat_update (void) { FILE *fp; int vnum; MOB_INDEX_DATA *pMobIndex; CHAR_DATA *mob; int nMatch; char buf[MSL]; fclose(fpReserve); fp = fopen("../data/mobstat.txt","w"); nMatch = 0; for (vnum = 0; nMatch < top_mob_index; vnum++) if ((pMobIndex = get_mob_index(vnum)) != NULL) { nMatch++; if ( ( pMobIndex = get_mob_index( vnum ) ) != NULL ) { mob = create_mobile( pMobIndex ); sprintf(buf,"%5d %5d %5d\n\r", mob->pIndexData->vnum,mob->pIndexData->kills, mob->pIndexData->killed); fprintf( fp, buf ); } } ********************************Was misplaced************************ fclose(fp); fpReserve = fopen( NULL_FILE, "r" ); return; **********************was here************************************ } Thanks for all who looked it over! -K -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Valnir Sent: Wednesday, August 04, 2004 9:38 AM To: [email protected] Subject: Re: Output to file loose the "\r" in the sprintf. that will fix it. - Valnir ----- Original Message ----- From: "Mervine, Keith" <[EMAIL PROTECTED]> To: "Mervine, Keith" <[EMAIL PROTECTED]>; <[email protected]> Sent: Wednesday, August 04, 2004 9:36 AM Subject: RE: Output to file My mistake...the code is actually this: void mobstat_update (void) { FILE *fp; int vnum; MOB_INDEX_DATA *pMobIndex; CHAR_DATA *mob; int nMatch; char buf[MSL]; fclose(fpReserve); fp = fopen("../data/mobstat.txt","w"); nMatch = 0; for (vnum = 0; nMatch < top_mob_index; vnum++) if ((pMobIndex = get_mob_index(vnum)) != NULL) { nMatch++; if ( ( pMobIndex = get_mob_index( vnum ) ) != NULL ) { mob = create_mobile( pMobIndex ); sprintf(buf,"%5d %5d %5d\n\r", mob->pIndexData->vnum, mob->pIndexData->kills, mob->pIndexData->killed); fprintf( fp, buf ); } fclose(fp); fpReserve = fopen( NULL_FILE, "r" ); return; } } -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mervine, Keith Sent: Wednesday, August 04, 2004 9:34 AM To: [email protected] Subject: Output to file I am having a problem with something. I want to output to file a list of all mob vnums Their kill totals and the total times they have been killed. When I let the update run, I get the following in the file.... 2 0 0 ^M Here is the code. Can someone let me know what I'm doing wrong? It should print out all existing mob vnums but it won't. Unless I am looking at it wrong(which I probably am) Ive also tried hardcoding a number for top_mob_index (32768) but to no avail. Cheers, -K -- ROM mailing list [email protected] http://www.rom.org/cgi-bin/mailman/listinfo/rom -- ROM mailing list [email protected] http://www.rom.org/cgi-bin/mailman/listinfo/rom -- ROM mailing list [email protected] http://www.rom.org/cgi-bin/mailman/listinfo/rom

