Solved

Process does stop by itself

Posted on 2015-01-25
37
127 Views
Last Modified: 2015-02-05
Hi,
when running the codes having these
#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 "..\..\include\nameval2.h"   
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <errno.h>
using namespace std;
nameval binrec;
int main()
{
	int cnt;
	int cnt_val = 0;
	std::ofstream files[40];
	std::ofstream file_w;
	std::set<nameval> records_w;
	std::ostringstream filename_w;
	filename_w << "c:\\dp4\\flout_w.bin";
	std::string strfilename_w = filename_w.str();
	file_w.open(strfilename_w.c_str(), std::ios::binary | std::ios::out);
	if (!file_w.is_open()) return errno;
	for (int f = 0; f < 40; ++f)
	{
		std::set<nameval> records;
		srand((int)time(NULL));
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		std::string strfilename = filename.str();
		files[f].open(strfilename.c_str(), std::ios::binary | std::ios::out);
		if (!files[f].is_open()) return errno;
		for (cnt = 0; cnt<1000000; cnt++)
		{
			cnt_val++;
			try
			{
				nameval val = { 0 };
				int j;
				for (j = 0; j<20; j++)
				{
					val.fld_nm[j] += (char)(rand() % 26 + ((rand() % 2) ? 65 : 97));
				}
				val.fld_val = cnt_val;
				records.insert(val);
				records_w.insert(val);
				if ((cnt + 1) % 10000 == 0)
				{
					std::cout << val.fld_val << " | " << val.fld_nm << std::endl;
				}
			}
			catch (exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
		{
			try
			{
				files[f].write((char *)&(*it), sizeof(nameval));
				file_w.write((char *)&(*it), sizeof(nameval));
			}
			catch (std::exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		records.clear();
		files[f].close();  //
	}
	std::ifstream inputfiles[40];
	nameval names[40] = { 0 };
	bool eof_reached[40] = { false };
	int num = 40;   //
	for (int f = 0; f < 40; ++f)
	{
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		inputfiles[f].open(filename.str().c_str(), std::ios::binary | std::ios::in);
		if (inputfiles[f].is_open())
			return -3; //
		if (!inputfiles[f].read((char*)&names[f], sizeof(nameval)))
			return -4; //
	}
	file_w.close();
	return 0;
}

Open in new window


that is with this .h file
// nameval.h
#ifndef NAME_VAL_H
#define NAME_VAL_H

struct nameval
{
     char fld_nm[100];
     size_t    fld_val;

     int  get_len() const
     {
         int len = strlen(fld_nm);
         if (len < (int)sizeof(fld_nm))
             return len;
         return (int)sizeof(fld_nm);
     }
     void get_uni_nm(wchar_t nm_uni[], int sizfld) const
     {
         int len = get_len();
         if (len > sizfld)
             len = sizfld;
         mbstowcs(nm_uni, fld_nm, len);
     }
     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;
     }
};

#endif

Open in new window


it does stop once the overall file has reached the size of 1GB. How to adjust it the above to overcome the problem?
0
Comment
Question by:HuaMinChen
  • 20
  • 13
  • 3
37 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40569216
for (cnt = 0; cnt<1000000; cnt++)

I can't compile your code unfortunately
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40569226
It can be compiled/executed using VS 2010/2013. Thanks.
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40569261
the file when it opens it doesn't catch the file not found and just carry's on into the loop
I had to add a #define and turn off precompiled headers.
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40569762
Can you show in details, what to adjust?
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40569955
Any other help to this?
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40569967
I realize that you wrote this for your own use BUT I have no idea of what you are trying to accomplish (add comments) and 6 months from now you won't know either. What is this program supposed to do?
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40570029
The process is handling with binary files.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40570106
it is not the right approach to write to the overall file while the partial files were written. instead, you would create and write all 40 files, each of them with 1 million of keys, and after all files exist reopen them as you do in your query program and then do a "merge" by reading from all 40 files and only write the minimum key of all the 40 keys to the overall file.

the merge loop is rather simple like this


while (true)
{
     std::string name_min;
     int n_min = -1;
      for (n = 0;n < 40; ++n)
      {
          if (eof_reached[n] == true) continue;
          if (name[n].fld_nm < name_min)
          {
                name_min = name[n].fld_nm;
                n_min = n;
                continue;
          }
    }
    if (n_min < 0) break; // if all files were closed you are done
    file_w.write((char*)&name[n_min], sizeof(name_val));
    if (!inputfile[n_min].read((char*)&name[n_min], sizeof(name_val)))
    {
          eof_reached[n_min] = true;
          inputfile[n_min].close();
    }
}

Open in new window


you would need arrays for std::ifstream and struct name_val and a bool array where you can see whether a file still has keys not merged.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40570148
Many thanks Sara.
Sorry I get these
Warning	1	warning C4947: 'RequestMinimum' : marked as obsolete	C:\SaveBinaryFile 150110\SaveBinaryFile\AssemblyInfo.cpp	40	1	SaveBinaryFile
Warning	2	warning C4996: 'mbstowcs': This function or variable may be unsafe. Consider using mbstowcs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	c:\include\nameval2.h	22	1	SaveBinaryFile
Error	3	error C2039: 'fld_nm' : is not a member of 'std::basic_ifstream<char,std::char_traits<char>>'	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	117	1	SaveBinaryFile
Error	4	error C2065: 'name' : undeclared identifier	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	119	1	SaveBinaryFile
Error	5	error C2228: left of '.fld_nm' must have class/struct/union	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	119	1	SaveBinaryFile
Error	6	error C2065: 'name' : undeclared identifier	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	125	1	SaveBinaryFile
Error	7	error C2065: 'name_val' : undeclared identifier	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	125	1	SaveBinaryFile
Error	8	error C2070: 'unknown-type': illegal sizeof operand	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	125	1	SaveBinaryFile
Error	9	error C2065: 'inputfile' : undeclared identifier	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	126	1	SaveBinaryFile
Error	10	error C2228: left of '.read' must have class/struct/union	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	126	1	SaveBinaryFile
Error	11	error C2065: 'name' : undeclared identifier	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	126	1	SaveBinaryFile
Error	12	error C2065: 'name_val' : undeclared identifier	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	126	1	SaveBinaryFile
Error	13	error C2070: 'unknown-type': illegal sizeof operand	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	126	1	SaveBinaryFile
Error	14	error C2065: 'inputfile' : undeclared identifier	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	129	1	SaveBinaryFile
Error	15	error C2228: left of '.close' must have class/struct/union	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	129	1	SaveBinaryFile
	16	IntelliSense: class "std::basic_ifstream<char, std::char_traits<char>>" has no member "fld_nm"	c:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	117	22	SaveBinaryFile
	17	IntelliSense: identifier "name" is undefined	c:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	119	16	SaveBinaryFile
	18	IntelliSense: identifier "name" is undefined	c:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	125	24	SaveBinaryFile
	19	IntelliSense: identifier "name_val" is undefined	c:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	125	44	SaveBinaryFile
	20	IntelliSense: identifier "inputfile" is undefined	c:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	126	8	SaveBinaryFile

Open in new window


with these
// SaveBinaryFile.cpp : main project file.

#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 "..\..\include\nameval2.h"   
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <errno.h>
using namespace std;
nameval binrec;
int main()
{
	int cnt;
	int cnt_val = 0;
	std::ofstream files[40];
	std::ofstream file_w;
	std::set<nameval> records_w;
	std::ostringstream filename_w;
	filename_w << "c:\\dp4\\flout_w.bin";
	std::string strfilename_w = filename_w.str();
	file_w.open(strfilename_w.c_str(), std::ios::binary | std::ios::out);
	if (!file_w.is_open()) return errno;
	for (int f = 0; f < 40; ++f)
	{
		std::set<nameval> records;
		srand((int)time(NULL));
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		std::string strfilename = filename.str();
		files[f].open(strfilename.c_str(), std::ios::binary | std::ios::out);
		if (!files[f].is_open()) return errno;
		for (cnt = 0; cnt<1000000; cnt++)
		{
			cnt_val++;
			try
			{
				nameval val = { 0 };
				int j;
				for (j = 0; j<20; j++)
				{
					val.fld_nm[j] += (char)(rand() % 26 + ((rand() % 2) ? 65 : 97));
				}
				val.fld_val = cnt_val;
				records.insert(val);
				//records_w.insert(val);
				if ((cnt + 1) % 10000 == 0)
				{
					std::cout << val.fld_val << " | " << val.fld_nm << std::endl;
				}
			}
			catch (exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
		{
			try
			{
				files[f].write((char *)&(*it), sizeof(nameval));
				file_w.write((char *)&(*it), sizeof(nameval));
			}
			catch (std::exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		records.clear();
		files[f].close();  //
	}
	std::ifstream inputfiles[40];
	nameval names[40] = { 0 };
	bool eof_reached[40] = { false };
	int num = 40;   //
	for (int f = 0; f < 40; ++f)
	{
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		inputfiles[f].open(filename.str().c_str(), std::ios::binary | std::ios::in);
		if (inputfiles[f].is_open())
			return -3; //
		if (!inputfiles[f].read((char*)&names[f], sizeof(nameval)))
			return -4; //
	}

	while (true)
	{
		std::string name_min;
		int n_min = -1;
		for (int n = 0; n < 40; ++n)
		{
			if (eof_reached[n] == true) continue;
			if (inputfiles[n].fld_nm < name_min)
			{
				name_min = name[n].fld_nm;
				n_min = n;
				continue;
			}
		}
		if (n_min < 0) break; // if all files were closed you are done
		file_w.write((char*)&name[n_min], sizeof(name_val));
		if (!inputfile[n_min].read((char*)&name[n_min], sizeof(name_val)))
		{
			eof_reached[n_min] = true;
			inputfile[n_min].close();
		}
	}
	file_w.close();
	system("pause>null");
	return 0;
}

Open in new window


and here is .h file

// nameval.h
#ifndef NAME_VAL_H
#define NAME_VAL_H

struct nameval
{
     char fld_nm[100];
     size_t    fld_val;

     int  get_len() const
     {
         int len = strlen(fld_nm);
         if (len < (int)sizeof(fld_nm))
             return len;
         return (int)sizeof(fld_nm);
     }
     void get_uni_nm(wchar_t nm_uni[], int sizfld) const
     {
         int len = get_len();
         if (len > sizfld)
             len = sizfld;
         mbstowcs(nm_uni, fld_nm, len);
     }
     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;
     }
};

#endif

Open in new window

0
 
LVL 32

Expert Comment

by:sarabande
ID: 40570244
you did not use the right names for the arrays in the while loop. hence the compiler complains.

also you still use wrong code lines which we already fixed in readbinaryfile project:

if (inputfiles[f].is_open()) must be corrected to if (!inputfiles[f].is_open()).

also you made new errors:

if (inputfiles[n].fld_nm < name_min) must be corrected to if (names[n].fld_nm < name_min)  and the next assignment statement must use names[n].fld_nm for the right-side term and not name[n].fld_nm.

also the struct name is 'nameval' and not 'name_val' which I used in the code snippet. it is very simple to correct these kind of errors if you would try to understand the meaning of the statement and read the error message thoroughly.

before you post an error you should try to double-click on the error in visual studio and try to fix the error yourself. it is almost every time a simple naming error or a mix-up of variables.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40572108
Many thanks Sara.
After I've increased total files to be 80 instead of 40

#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 "..\..\include\nameval2.h"   
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <errno.h>
using namespace std;
nameval binrec;
int main()
{
	int cnt;
	int cnt_val = 0;
	std::ofstream files[80];
	std::ofstream file_w;
	std::set<nameval> records_w;
	std::ostringstream filename_w;
	filename_w << "c:\\dp4\\flout_w.bin";
	std::string strfilename_w = filename_w.str();
	file_w.open(strfilename_w.c_str(), std::ios::binary | std::ios::out);
	if (!file_w.is_open()) return errno;
	for (int f = 0; f < 80; ++f)
	{
		std::set<nameval> records;
		srand((int)time(NULL));
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		std::string strfilename = filename.str();
		files[f].open(strfilename.c_str(), std::ios::binary | std::ios::out);
		if (!files[f].is_open()) return errno;
		for (cnt = 0; cnt<1000000; cnt++)
		{
			cnt_val++;
			try
			{
				nameval val = { 0 };
				int j;
				for (j = 0; j<20; j++)
				{
					val.fld_nm[j] += (char)(rand() % 26 + ((rand() % 2) ? 65 : 97));
				}
				val.fld_val = cnt_val;
				records.insert(val);
				//records_w.insert(val);
				if ((cnt + 1) % 10000 == 0)
				{
					std::cout << val.fld_val << " | " << val.fld_nm << std::endl;
				}
			}
			catch (exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
		{
			try
			{
				files[f].write((char *)&(*it), sizeof(nameval));
				//file_w.write((char *)&(*it), sizeof(nameval));
			}
			catch (std::exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		records.clear();
		files[f].close();  //
	}
	std::ifstream inputfiles[80];
	nameval names[80] = { 0 };
	bool eof_reached[80] = { false };
	int num = 80;   //
	for (int f = 0; f < 80; ++f)
	{
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		inputfiles[f].open(filename.str().c_str(), std::ios::binary | std::ios::in);
		if (inputfiles[f].is_open())
			return -3; //
		if (!inputfiles[f].read((char*)&names[f], sizeof(nameval)))
			return -4; //
	}

	while (true)
	{
		std::string name_min;
		int n_min = -1;
		for (int n = 0; n < 80; ++n)
		{
			if (eof_reached[n] == true) continue;
			if (names[n].fld_nm < name_min)
			{
				name_min = names[n].fld_nm;
				n_min = n;
				continue;
			}
		}
		if (n_min < 0) break; // if all files were closed you are done
		file_w.write((char*)&names[n_min], sizeof(nameval));
		if (!inputfiles[n_min].read((char*)&names[n_min], sizeof(nameval)))
		{
			eof_reached[n_min] = true;
			inputfiles[n_min].close();
		}
	}
	file_w.close();
	system("pause>null");
	return 0;
}

Open in new window

it seems it cannot generate the overall file properly. Any ideas?
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40572590
it seems it cannot generate the overall file properly. Any ideas?
yes. I already told you that the number of 40 is crucial to have a file size below 4gb. many programs - including the current readbinaryfile program, do have problems to handle bigger files because they use 32-bit integers where then 64-bit integers are required or use functions which have 32-bit integers for file size and file positions. for example the stat function and stat struct used to retrieve the file size needs to be replaced by _stat64. also all variables begin, mid, end, ... in the binary search loop. before doing that it would be much easier to decrease size of fld_nm to 21 characters. this little change would allow to increase the number of names by factor 4 and still have a overall file less than 4gb.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40572926
Does it mean we should have the file size of 4GB at most? Thanks a lot.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40573041
not necessarily. as I told in a former thread, it is not very likely that you ever would need a dictionary with more than 40 million of names. but the names of all inhabitants of - say - China is more than a billion. for that use case 160 million of names is too less.

so it depends on the goal you have whether it makes sense to expand the number of keys and have the efforts to make all working code capable to handle files greater than 4 gb. you may also consider that such a size will cause other issues, for example you can't copy it to an usb-stick and probably you will not be able to upload it within reasonable time even if the cloud would allow it at all. you can't put it to a dvd or blue-ray without problems. so, the only way left is to copy the file by network to a target device which is able to receive such files. or, you send the single files and provide a separate merge module which does the merging at the target device.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40574320
Many thanks Sara.
Do you know why it stops now, when running the current codes?
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40574727
so it depends on the goal you have whether it makes sense to expand the number of keys and have the efforts to make all working code capable to handle files greater than 4 gb. you may also consider that such a size will cause other issues, for example you can't copy it to an usb-stick and probably you will not be able to upload it within reasonable time even if the cloud would allow it at all. you can't put it to a dvd or blue-ray without problems. so, the only way left is to copy the file by network to a target device which is able to receive such files. or, you send the single files and provide a separate merge module which does the merging at the target device.

Thanks a lot Sara.
Suppose that the created file would only stay on the Hard drive in there, the question is, if we should create file having the size of more than 4 GB, or not.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40577145
the question is, if we should create file having the size of more than 4 GB, or not.
yes, you must decide whether you have attained the end you had in view, or not ...

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40577545
Sorry, why did the current codes stop in there, when running the project? Thanks.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 32

Expert Comment

by:sarabande
ID: 40578009
it seems that std::ofstream was not able to write a file > 4gb on your system.

to be sure you could add the following statements at begin of main and check the value of temp by outputting it to std::cout or by evaluating it with the debugger.

include <streambuf>
...

__int64_t temp=std::numeric_limits<std::streamsize>::max();

Open in new window


if the temp shows 4.21 billion it would be the limit both for std::ofstream and std::ifstream.

if that is the case you could use OpenFile/CreateFile/ReadFile/WriteFile of the winapi or fopen/fread/fwrite/fsetpos of c runtime instead.

for example I created a file of 5.58 gb by

#include <stdio.h>

int createfile(fpos_t filesize)
{
    FILE * pf = fopen("c:\\temp\\hugefile.dat", "wb");
    if (pf)
    {
        fpos_t pos = filesize-1;   // i used 6000000000;
        int ret = fsetpos(pf, &pos);
        if (ret != 0)
            std::cout << "fopen " << ret << std::endl;
        if (ret == 0)
        {
            fwrite("\0", 1, 1, pf);
            fclose(pf);
        }
    }
    return ret;
}

Open in new window


fpos_t is typedef'd as 'long long' what is _int64 type. file creation lasted about 10 minutes on a non-ssd drive.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40579039
Hi,
How to list out all t-sql codes within the database, that is doing any change against one specific table name?
Sorry, any advice to these
Error	3	error C2146: syntax error : missing ';' before identifier 'temp'	C:\SaveBinaryFile\SaveBinaryFile.cpp	21	1	SaveBinaryFile
Error	4	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	C:\SaveBinaryFile\SaveBinaryFile.cpp	21	1	SaveBinaryFile

Open in new window

with these codes
//
//
#include "stdafx.h"
#include <set>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <streambuf>
#include <string>
#include <ctype.h>
#include <time.h>
#include <process.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include "..\..\include\nameval2.h"   
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <errno.h>
__int64_t temp = std::numeric_limits<std::streamsize>::max();
...

Open in new window

0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40579060
Sorry, please omit the 1st line to the current reply of me.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40579246
you may try 'long long' instead of __int64_t

class std::numeric_limits is available thru the header <limits>.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40579432
Sorry, using these
// 

#include "stdafx.h"
#include <set>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <streambuf>
#include <string>
#include <ctype.h>
#include <time.h>
#include <process.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include "..\..\include\nameval2.h"   
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <errno.h>
#include <limits>
long long temp = std::numeric_limits<std::streamsize>::max();
using namespace std;
nameval binrec;
int main()
{
	int cnt;
	int cnt_val = 0;
	std::ofstream files[80];
	std::ofstream file_w;
	std::set<nameval> records_w;
	std::ostringstream filename_w;
	filename_w << "c:\\dp4\\flout_w.bin";
	std::string strfilename_w = filename_w.str();
	file_w.open(strfilename_w.c_str(), std::ios::binary | std::ios::out);
	if (!file_w.is_open()) return errno;
	for (int f = 0; f < 80; ++f)
	{
		std::set<nameval> records;
		srand((int)time(NULL));
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		std::string strfilename = filename.str();
		files[f].open(strfilename.c_str(), std::ios::binary | std::ios::out);
		if (!files[f].is_open()) return errno;
		for (cnt = 0; cnt<1000000; cnt++)
		{
			cnt_val++;
			try
			{
				nameval val = { 0 };
				int j;
				for (j = 0; j<20; j++)
				{
					val.fld_nm[j] += (char)(rand() % 26 + ((rand() % 2) ? 65 : 97));
				}
				val.fld_val = cnt_val;
				records.insert(val);
				//records_w.insert(val);
				if ((cnt + 1) % 10000 == 0)
				{
					std::cout << val.fld_val << " | " << val.fld_nm << std::endl;
				}
			}
			catch (exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
		{
			try
			{
				files[f].write((char *)&(*it), sizeof(nameval));
				//file_w.write((char *)&(*it), sizeof(nameval));
			}
			catch (std::exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		records.clear();
		files[f].close();  //
	}
	std::ifstream inputfiles[80];
	nameval names[80] = { 0 };
	bool eof_reached[80] = { false };
	int num = 80;   //
	for (int f = 0; f < 80; ++f)
	{
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		inputfiles[f].open(filename.str().c_str(), std::ios::binary | std::ios::in);
		if (inputfiles[f].is_open())
			return -3; //
		if (!inputfiles[f].read((char*)&names[f], sizeof(nameval)))
			return -4; //
	}

	while (true)
	{
		std::string name_min;
		int n_min = -1;
		for (int n = 0; n < 80; ++n)
		{
			if (eof_reached[n] == true) continue;
			if (names[n].fld_nm < name_min)
			{
				name_min = names[n].fld_nm;
				n_min = n;
				continue;
			}
		}
		if (n_min < 0) break; // if all files were closed you are done
		file_w.write((char*)&names[n_min], sizeof(nameval));
		if (!inputfiles[n_min].read((char*)&names[n_min], sizeof(nameval)))
		{
			eof_reached[n_min] = true;
			inputfiles[n_min].close();
		}
	}
	file_w.close();
	system("pause>null");
	return 0;
}

Open in new window


the overall file still cannot be created. CAn I know what I should adjust to .h file?
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40579513
the code should be at top of main function, not above main function. what is the value of 'temp' ?

if it is 32-bit maximum you can't use ifstream and ofstream when using the current nameval structure with 104 bytes in size.


CAn I know what I should adjust to .h file?
if you change fld_nm[100] to fld_nm[21] it should work with 80 to about 170 files.

the formula for the maximum of files within the 4 gb limit is  

long long max_ushort = 65536;
long long max_uint     = max_ushort * max_ushort;

long long max_files    = max_uint / (sizeof(nameval)  * 1000000);

Open in new window


note, use 'long long' or size_t for all integer variables to avoid wrong results because of integer overflow.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40580903
Many thanks Sara.
What is the use of "temp"?
I adjust the length of fld_nm to 21, within .h file, but I still get no overall file generated, with these

// 

#include "stdafx.h"
#include <set>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <streambuf>
#include <string>
#include <ctype.h>
#include <time.h>
#include <process.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include "..\..\include\nameval2.h"   
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <errno.h>
#include <limits>

using namespace std;
nameval binrec;
int main()
{
	long long temp = std::numeric_limits<std::streamsize>::max();
	long long cnt;
	long long cnt_val = 0;
	std::ofstream files[80];
	std::ofstream file_w;
	std::set<nameval> records_w;
	std::ostringstream filename_w;
	filename_w << "c:\\dp4\\flout_w.bin";
	std::string strfilename_w = filename_w.str();
	file_w.open(strfilename_w.c_str(), std::ios::binary | std::ios::out);
	if (!file_w.is_open()) return errno;
	for (int f = 0; f < 80; ++f)
	{
		std::set<nameval> records;
		srand((int)time(NULL));
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		std::string strfilename = filename.str();
		files[f].open(strfilename.c_str(), std::ios::binary | std::ios::out);
		if (!files[f].is_open()) return errno;
		for (cnt = 0; cnt<1000000; cnt++)
		{
			cnt_val++;
			try
			{
				nameval val = { 0 };
				int j;
				for (j = 0; j<20; j++)
				{
					val.fld_nm[j] += (char)(rand() % 26 + ((rand() % 2) ? 65 : 97));
				}
				val.fld_val = cnt_val;
				records.insert(val);
				//records_w.insert(val);
				if ((cnt + 1) % 10000 == 0)
				{
					std::cout << val.fld_val << " | " << val.fld_nm << std::endl;
				}
			}
			catch (exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
		{
			try
			{
				files[f].write((char *)&(*it), sizeof(nameval));
				//file_w.write((char *)&(*it), sizeof(nameval));
			}
			catch (std::exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		records.clear();
		files[f].close();  //
	}
	std::ifstream inputfiles[80];
	nameval names[80] = { 0 };
	bool eof_reached[80] = { false };
	long long num = 80;   //
	for (int f = 0; f < 80; ++f)
	{
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		inputfiles[f].open(filename.str().c_str(), std::ios::binary | std::ios::in);
		if (inputfiles[f].is_open())
			return -3; //
		if (!inputfiles[f].read((char*)&names[f], sizeof(nameval)))
			return -4; //
	}

	while (true)
	{
		std::string name_min;
		long long n_min = -1;
		for (int n = 0; n < 80; ++n)
		{
			if (eof_reached[n] == true) continue;
			if (names[n].fld_nm < name_min)
			{
				name_min = names[n].fld_nm;
				n_min = n;
				continue;
			}
		}
		if (n_min < 0) break; // if all files were closed you are done
		file_w.write((char*)&names[n_min], sizeof(nameval));
		if (!inputfiles[n_min].read((char*)&names[n_min], sizeof(nameval)))
		{
			eof_reached[n_min] = true;
			inputfiles[n_min].close();
		}
	}
	file_w.close();
	system("pause>null");
	return 0;
}

Open in new window


and here is .h file
// nameval.h
#ifndef NAME_VAL_H
#define NAME_VAL_H

struct nameval
{
     char fld_nm[21];
     long long    fld_val;

     int  get_len() const
     {
         int len = strlen(fld_nm);
         if (len < (int)sizeof(fld_nm))
             return len;
         return (int)sizeof(fld_nm);
     }
     void get_uni_nm(wchar_t nm_uni[], int sizfld) const
     {
         int len = get_len();
         if (len > sizfld)
             len = sizfld;
         mbstowcs(nm_uni, fld_nm, len);
     }
     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;
     }
};

#endif

Open in new window

0
 
LVL 32

Expert Comment

by:sarabande
ID: 40581228
the temp is only to find out whether class std::streambuf is capable for file positions > 4 GB or not.

std::streambuf is used both by ifstream and ofstream classes.

long long    fld_val;

you only need to use 'long long' for 'int' where numbers greater 2 billion are possible. fld_val is less equal to 80 million. so, it is safe to use an 'int'.

can you post the output of your command window? what happens when you say that the 'output file' was not created?

did it create the 80 input files? did it open the big file? did you delete old files before? this is necessary since you changed the record size.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40581408
Many thanks Sara.
Yes, all eighty files have been created and only the big file cannot. I did delete all files and I tested it by directly running the exe file.
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40586224
Sara,
Here are what I get from VS, after I've finished re-running it, while the big file still has not been created.
'SaveBinaryFile.exe': Loaded 'C:\dp10\CPP\SaveBinaryFile 150110\Debug\SaveBinaryFile.exe', Symbols loaded.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\mscoree.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\msvcr120d.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\msvcp120d.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\msvcr120_clr0400.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\d1265d6159ea876f9d63ea4c1361b587\mscorlib.ni.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe' (Managed (v4.0.30319)): Loaded 'C:\dp10\CPP\SaveBinaryFile 150110\Debug\SaveBinaryFile.exe', Symbols loaded.
'SaveBinaryFile.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clrjit.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System\d18e2115a3270f89663fce831547f534\System.ni.dll', Cannot find or open the PDB file.
'SaveBinaryFile.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'Win32 Thread' (0x56c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xac0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x764) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1114) has exited with code -3 (0xfffffffd).
The thread 'Win32 Thread' (0x1110) has exited with code -3 (0xfffffffd).
The thread 'Win32 Thread' (0xb54) has exited with code -3 (0xfffffffd).
The program '[1252] SaveBinaryFile.exe: Native' has exited with code -3 (0xfffffffd).
The program '[1252] SaveBinaryFile.exe: Managed (v4.0.30319)' has exited with code -3 (0xfffffffd).

Open in new window

0
 
LVL 32

Expert Comment

by:sarabande
ID: 40586330
has exited with code -3

this is because of

if (inputfiles[f].is_open())
     return -3;

Open in new window


which I corrected a few times cause it should be

if (!inputfiles[f].is_open())
     return -3;

Open in new window


I wonder why you returned to old (wrong) code while we already had a working solution with 40 files. why not simply replace '40' by '80' in the 'good' and 'working' source code?

note, when using the shorter nameval structure, the overall file is less than 4 gb. because of that you still could use 'unsigned int' instead of 'long long' even for file positions. the 'long long' or '_int64' or 'size_t' (what is all the same for your compiler) is needed if you go beyond 4 gb for all positions in the overall file, especially for the binary search. you also must use a 64 bit integer if you assign std::numeric_limits<std::streamsize>::max() . I wanted you to add this call at begin of main function and output the result (to std::cout) such that we know for sure that the ifstream and ofstream class are 32-bit only (even for your 64-bit project).

I didn't try it myself, but there is a 64-bit version of visual studio which came with a 64-bit compiler. the 64-bit compiler should use a standard library which has a 64-bit maximum for std::streamsize. if so, std::ifstream and std::ofstream should work also for files greater 4 gb. so if you still thinking of using files > 4 gb you may consider to install a 64-bit version of visual studio and try again.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40587806
you also must use a 64 bit integer if you assign std::numeric_limits<std::streamsize>::max() . I wanted you to add this call at begin of main function and output the result (to std::cout) such that we know for sure that the ifstream and ofstream class are 32-bit only (even for your 64-bit project).

Many thanks Sara. I changed the project's Configuration to be x64 and re-reran it, while the big file still cannot be generated. can you tell me how I can refer to this below?
 
std::numeric_limits<std::streamsize>::max()
0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 500 total points
ID: 40588048
I changed the project's Configuration to be x64
that was not necessary. as long as the std::set would not contain more than 1 million keys, it is still possible to using a win32 project. you need an x64 project because of the memory requirements and not because of the file sizes.

std::numeric_limits<std::streamsize>::max()

int main(...)
{
     long long integer_limit = std::numeric_limits<std::streamsize>::max();
     std::cout << "the maximum int value is " << integer_limit << std::endl;
     ....

Open in new window


while the big file still cannot be generated.
please add output statements before each error return. if you run the program from visual studio also set a break point to each return statement.

also check the error of the write statement within the final while(true) loop and add an output statement that shows the progress after writing 10.000 keys.

unsigned int write_counter = 0;
while (true)
{
         ....
        if (!file_w.write((char*)&names[n_min], sizeof(nameval)))
        {
               std::cout << "write error " << GetLastError() << " at " 
                                << write_counter << " key= " << names[n_min].fld_nm << std::endl;
               return -5;
        }
        if ((++write_counter)%10000 == 0)
        {
            std::cout << write_counter << " n_min = " << n_min << "  fld_nm = " << names[n_min].fld_nm << "std::endl";
        }
        ...

Open in new window

0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40588065
Thanks a lot. I apply your codes but have got these
Error	4	error C3861: 'GetLastError': identifier not found	C:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	141	1	SaveBinaryFile
	5	IntelliSense: identifier "GetLastError" is undefined	c:\SaveBinaryFile 150110\SaveBinaryFile\SaveBinaryFile.cpp	141	35	SaveBinaryFile

Open in new window

0
 
LVL 32

Expert Comment

by:sarabande
ID: 40588307
hmmm. the stdafx.h normally includes <windows.h> where the GetLastError was declared. I wonder whether the error was due to the 'x64' project.

but you can exchange 'GeLastError()' by 'errno' which was available thru errno.h.

nevertheless, please post the contents of stdafx.h such that we could use winapi functions  if necessary.

Sara
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40588316
Sorry, I do not have specific file

stdafx.h

to the project. Thanks a lot.
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40590251
Many thanks Sara.
I get this
the maximum int value is 9223372036854775807

Open in new window


and the big file is still having 0 size after I've re-run it. Here are the codes
//

#include "stdafx.h"
#include <set>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <streambuf>
#include <string>
#include <ctype.h>
#include <time.h>
#include <process.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include "..\..\include\nameval2.h"   
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <errno.h>
#include <limits>

using namespace std;
nameval binrec;
int main()
{
	long long integer_limit = std::numeric_limits<std::streamsize>::max();
	std::cout << "the maximum int value is " << integer_limit << std::endl;

	long long temp = std::numeric_limits<std::streamsize>::max();
	long long cnt;
	long long cnt_val = 0;
	std::ofstream files[80];
	std::ofstream file_w;
	std::set<nameval> records_w;
	std::ostringstream filename_w;
	filename_w << "c:\\dp4\\flout_w.bin";
	std::string strfilename_w = filename_w.str();
	file_w.open(strfilename_w.c_str(), std::ios::binary | std::ios::out);
	if (!file_w.is_open()) return errno;
	for (int f = 0; f < 80; ++f)
	{
		std::set<nameval> records;
		srand((int)time(NULL));
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		std::string strfilename = filename.str();
		files[f].open(strfilename.c_str(), std::ios::binary | std::ios::out);
		if (!files[f].is_open()) return errno;
		for (cnt = 0; cnt<1000000; cnt++)
		{
			cnt_val++;
			try
			{
				nameval val = { 0 };
				int j;
				for (j = 0; j<20; j++)
				{
					val.fld_nm[j] += (char)(rand() % 26 + ((rand() % 2) ? 65 : 97));
				}
				val.fld_val = cnt_val;
				records.insert(val);
				//records_w.insert(val);
				if ((cnt + 1) % 10000 == 0)
				{
					std::cout << val.fld_val << " | " << val.fld_nm << std::endl;
				}
			}
			catch (exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		for (std::set<nameval>::iterator it = records.begin(); it != records.end(); ++it)
		{
			try
			{
				files[f].write((char *)&(*it), sizeof(nameval));
				//file_w.write((char *)&(*it), sizeof(nameval));
			}
			catch (std::exception& e)
			{
				std::cout << e.what() << '\n';
			}
		}
		records.clear();
		files[f].close();  //
	}
	std::ifstream inputfiles[80];
	nameval names[80] = { 0 };
	bool eof_reached[80] = { false };
	long long num = 80;   //
	for (int f = 0; f < 80; ++f)
	{
		std::ostringstream filename;
		filename << "c:\\dp4\\flout" << f << ".bin";
		inputfiles[f].open(filename.str().c_str(), std::ios::binary | std::ios::in);
		if (!inputfiles[f].is_open())
			return -3; //
		if (!inputfiles[f].read((char*)&names[f], sizeof(nameval)))
			return -4; //
	}

	long long write_counter;
	write_counter = 0;
	while (true)
	{
		std::string name_min;
		long long n_min = -1;
		for (int n = 0; n < 80; ++n)
		{
			if (eof_reached[n] == true) continue;
			if (names[n].fld_nm < name_min)
			{
				name_min = names[n].fld_nm;
				n_min = n;
				continue;
			}
		}
		if (n_min < 0) break; // if all files were closed you are done
		file_w.write((char*)&names[n_min], sizeof(nameval));
		if (!inputfiles[n_min].read((char*)&names[n_min], sizeof(nameval)))
		{
			eof_reached[n_min] = true;
			inputfiles[n_min].close();
		}
		if (!file_w.write((char*)&names[n_min], sizeof(nameval)))
		{
			std::cout << "write error " << errno << " at "
				<< write_counter << " key= " << names[n_min].fld_nm << std::endl;
			return -5;
		}
		if ((++write_counter) % 10000 == 0)
		{
			std::cout << write_counter << " n_min = " << n_min << "  fld_nm = " << names[n_min].fld_nm << "std::endl";
		}
	}
	file_w.close();
	system("pause>null");
	return 0;
}

Open in new window

0
 
LVL 32

Accepted Solution

by:
sarabande earned 500 total points
ID: 40590946
the maximum int value is 9223372036854775807
so the problem is not the 4gb boundary. the streambuf of the stl used can handle big sizes.

std::string name_min;
.....
     if (names[n].fld_nm < name_min) // that never is true
           ....

the reason why the merge doesn't work is because name_min was not rightly initialized. it is initially empty and therefore the empty string always is less than any of the strings read from the files.

use the following if statement to fix the bug:

 if (n_min < 0 || names[n].fld_nm < name_min)

Open in new window


by this, always the first valid name was used as the start minimum.

Sara
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now