If this is your first visit, be sure to
check out the Forum Rules by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I'm sure you're interested in learning C++ or something but this really seems like re-inventing the wheel. Perhaps you're some kind of Uber Programming Personage but it seems doubtful that you're going to come up with something which is more optimized that a database w/ query parser/execution.

Also in your posted code you tested that the input file opened successfully but you didn't check that your output file did.

I'm a compulsive post editor, you might wanna wait until my post has been online for 5-10 mins before quoting it as it will likely change.

I know I seem harsh in some of my replies. SORRY! But if you're doing something illegal or posting something that seems to be obvious BS I'm going to call you on it.

I'm sure you're interested in learning C++ or something but this really seems like re-inventing the wheel.

This is one of the ways I learn, It's not reinventing the wheel its programming it in a different language. It's more like creating a rubber wheel, or a wooden wheel, or a steel wheel. Its not reinventing it... Its just made with different components.

Originally Posted by thorin

Perhaps you're some kind of Uber Programming Personage but it seems doubtful that you're going to come up with something which is more optimized that a database w/ query parser/execution.

This is not my intent.

Originally Posted by thorin

Also in your posted code you tested that the input file opened successfully but you didn't check that your output file did.

Its not necessary, If the file exists it opens it and writes to the file, If the file doesn't exist it creates it then opens it for writing.

hello,
first, if you want make fast i/o with fstream class, is better if you remove the synchronization between stdio and fstream. just call "std::ios_base::sync_with_stdio(false);" before use fstream class.
second if you want sort huge file (file that don't fit in memory) try to read same chunks in memory and use quick sort on they, after use merge sort on the chucks to create an huge sorted file.
third use a std::string like key value in std::map is slow, usually if you can, try to use a type with a fast "< operator" for the key value.

hello,
first, if you want make fast i/o with fstream class, is better if you remove the synchronization between stdio and fstream. just call "std::ios_base::sync_with_stdio(false);" before use fstream class.
second if you want sort huge file (file that don't fit in memory) try to read same chunks in memory and use quick sort on they, after use merge sort on the chucks to create an huge sorted file.
third use a std::string like key value in std::map is slow, usually if you can, try to use a type with a fast "< operator" for the key value.

Since I prefer to use "using namespace std;" I should declare it like this?

Code:

ios_base sync_with_stdio(false);

Does it matter if I declare this in the global or local scope?

I'm reading as much as I can about how to code the sorting into this which is why I haven't posted on this for a while. There's just soo many ways to do it.

The only values I know for words like in this case are string or char.
I came to the conclusion that since the lengths of the strings and the length of the file were unknown that it would be really difficult to use an array of chars. I think it would be necessary to use 3 dimensional arrays if I went with the char route.

Since I prefer to use "using namespace std;" I should declare it like this?

Code:

ios_base sync_with_stdio(false);

yes, if you use "using namespace std;" you can remove the "std::", bat usually is not a good choice open the namespace with the statement "using namespace". so, open the namespace in the little program, bat not in big project.

Originally Posted by hhmatt81

Does it matter if I declare this in the global or local scope?

no, you can call sync_with_stdio(true) or sync_with_stdio(false) anyware.

Originally Posted by hhmatt81

The only values I know for words like in this case are string or char.
I came to the conclusion that since the lengths of the strings and the length of the file were unknown that it would be really difficult to use an array of chars. I think it would be necessary to use 3 dimensional arrays if I went with the char route.

sure, i give you just an hint on general use of std::map(), just keep in mind when you use maps to use the fast type for key value