troubleshooting Question

Problem with the memory

Avatar of Peter Chan
Peter ChanFlag for Hong Kong asked on
Operating SystemsCC++
19 Comments4 Solutions362 ViewsLast Modified:
I do get the attached error

using these codes

#include "stdafx.h"
#include <set>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <string>
#include <ctype.h>
#include <time.h>
#include <process.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

struct nameval
	char fld_nm[100];
	wchar_t fld_nm_t[100];
     bool operator< (const nameval & a2) const
           if(strcmp(fld_nm, a2.fld_nm) < 0) return true;
           if(strcmp(fld_nm, a2.fld_nm) > 0) return false;
           if (fld_val < a2.fld_val) return true;
           return false;
	int fld_len;
	int fld_val;
nameval binrec;

int main()
    std::set<nameval> records;
    int cnt;
	for (cnt=0;cnt<8000000;cnt++)
		nameval val={0};
		int j;
		for (j=0;j<20;j++)
			val.fld_nm[j] += (char)(rand () % 58 + 64);
		wchar_t wbuf[100]={0};


	std::ofstream ostrm("c:\\dp4\\flout.bin", std::ios::binary | std::ios::out );
	if (ostrm.is_open())
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
			ostrm.write((char *)&records, sizeof(nameval));

	std::wofstream ostrm2("c:\\dp4\\flout.ord", std::ios::out );
	if (ostrm2.is_open())
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
			ostrm2 << "\"" << it->fld_nm << "\" " << it->fld_len << ' '  << it->fld_nm_t << ' '<< it->fld_val << '\0' << '\n';


	return 0;

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros