
-----------------------------------
Justin_
Wed Aug 16, 2006 12:47 am

Sex up an array?
-----------------------------------
Hello hello hello boys and girls, can you feel the energy cause I can!

Enough of that.  Now, how do we make a supercharged turbo ultra array in C++??  I'm open to using some of the STL if it will provide me with the functionality I need, but basically writing a file to an array is not working with a 6MB file.

-----------------------------------
Justin_
Wed Aug 16, 2006 12:56 am


-----------------------------------
Basically I'm looking for a method congenial to the windows API which seems to be more C-ish.  I've looked at the malloc function, is that the best bet?

-----------------------------------
[Gandalf]
Wed Aug 16, 2006 1:25 am


-----------------------------------
#include  //part of the STL

-----------------------------------
Justin_
Wed Aug 16, 2006 1:40 am


-----------------------------------
I cannot find a function that returns a pointer to an array in the vector class.  

I see a variable named "pointer" but I don't think that works, maybe wtd has a hint.

-----------------------------------
wtd
Wed Aug 16, 2006 3:45 am


-----------------------------------
Use STL algorithms.

vector foo(10);
// initialize

int *bar = new int[foo.size()];

copy(foo.begin(), foo.end(), bar);

-----------------------------------
Justin_
Wed Aug 16, 2006 4:04 am


-----------------------------------
Clever...  Really, I wish I had devoted more time into the STL.

-----------------------------------
Justin_
Wed Aug 16, 2006 4:15 am


-----------------------------------
But actually, the impractibility of creating a vector and then an array when both hold the same contents is stupifying and needless to say inefficient.  

Unless it really is just one buffer and the the vector and the pointer both point to it?  

If not, when dealing with the windows API, my opinion would be to stick with the C-arrays.

-----------------------------------
wtd
Wed Aug 16, 2006 11:27 am


-----------------------------------
http://en.wikipedia.org/wiki/Windows_Template_Library

-----------------------------------
wtd
Wed Aug 16, 2006 11:29 am


-----------------------------------
http://en.wikipedia.org/wiki/Windows_Template_Library

-----------------------------------
Justin_
Wed Aug 16, 2006 12:30 pm


-----------------------------------
What kind of struck me is that it is unsupported.  The other thing is that I have never seen documentation for this newer library.  As confusing as MSDN is I'd still prefer to go there and find the system call I need, even if that means giving up fancy vectors.  

Maybe in the future, if I ever become interested in high level programming, I'll look into it.  But the thing is, it wouldn't be that hard to create a "vector like" array and design it specifically for the win32 API so like I say, in my opinion its best to stay with C-style arrays.

-----------------------------------
wtd
Wed Aug 16, 2006 1:13 pm


-----------------------------------
You'll notice that all of the obstacles you're finding to using somewhat sane programming practices are rooted in the fact that you're doing straight Win32 API programming.

No one in their right mind does this.  They either use the plentiful, free, cross-platform GUI toolkits, or more modern Microsoft-exclusive technologies.

-----------------------------------
md
Wed Aug 16, 2006 2:11 pm


-----------------------------------
Speak for yourself! I use strait win32 APIs (or did) when I wrote win32 code... but that was to do things like process management and very simple window management. Doing anything more then that is crazy.

Justin_ many solutions to your problem have been proposed here, choose one; or do some research on your own. I am willing to bet others have had to deal with this before you.

Oh, and C != C++. Why would you want to use C constructs in C++ instead of C++ constructs? Maybe you should look at C or Objective C instead of C++.

-----------------------------------
Justin_
Wed Aug 16, 2006 2:29 pm


-----------------------------------
Yes, its too bad about the Win32 API.  And since we are on the topic of my sanity lets write an article all about: me.  

I'm more interested in lower level programming, assembly makes sense to me, where as the higher level languages seem to take simple concepts (or at least I find them simple) from asm and they wrap them up and keep wrapping, until such a simple thing becomes so convoluted it is complicated.  

I admit I once programmed a win32 window using the arcane win32 api, but that was for educational purposes and I think at that time I didn't know any better.  But for all intensive purposes I never use a low level programming language unless I'm learning, or if I can think of no other way (Due to not knowing the, for instance, STL).  

And finally a note to wtd: the gap between your programming knowledge and mine is quite substantial.  I have been programming for less than a year and in that time have created not one single half-decent application.    It should be no surprise that talking to me must seem like talking to a child.  So please try to be nice to me cause my feelings are hurt as easily as a child's too     :wink: 

Also, are you saying it would be easier to code a file binder using a GUI programming toolset or something like C#?  While I'm sure those tools would be easier it would be the equivelant of me driving a car to learn how to fix it, don't you think?  The whole point is learning for me, so if knowledge can be attained, it isn't time unworthy.

-----------------------------------
wtd
Wed Aug 16, 2006 5:39 pm


-----------------------------------
First off...

Being insane is not a bad thing.  ;)

Second, I view this from the perspective of Win32 API knowledge being largely useless.  There is a lot to be learned out there that is not tied to a proprietary operating system that moves at a snail's pace technologically and is tied to a massive company in slow bureaucratic decline.

-----------------------------------
Justin_
Wed Aug 16, 2006 5:43 pm


-----------------------------------
Agreed, that's why instead of learning the win32 API I use MSDN and search when I need to do something in windows.  MSDN is like an extended part of my brain in that regard.  (When I program for windows) 

To be honest I don't know any libraries that are cross platform and offer the same abilities as the win32 API, that is why it is best to use the tools it offers when programming in windows.  Do you not agree?

-----------------------------------
wtd
Wed Aug 16, 2006 5:48 pm


-----------------------------------
What kind of abilities do you feel you really need?

-----------------------------------
Justin_
Wed Aug 16, 2006 6:05 pm


-----------------------------------
It would depend on the application now wouldn't it?  

Basically the way it works is: some (forgive me for saying, but, limited) programs would be your cross platform library candidates and other more extended applications for windows would be very difficult to port.  

My favorite saying when programming in windows is, "When in Rome."

-----------------------------------
md
Wed Aug 16, 2006 7:48 pm


-----------------------------------
Unfortunately the POSIX layer is all but usless in windows now, but it used to be the case that windows provided a mostly POSIX conforment API so that most things that didn't rely on the GUI API were almost completely cross platform with only minor changes.

In fact many the programs that matter most are largely independent of hte operating system and only need to interact with it for IO; things like servers, etc. Applications that requier a complex GUI (like a text editor) *could* be written using the win32 API, or they could be written to use a crossplatform GUI (like say GTK or QT) which do all the same things as the win32 API but are mostly cross platform.

Oh, and just because you are in rome, doesn't mean you have to make the same mistakes that they make ;)

-----------------------------------
Justin_
Wed Aug 16, 2006 9:52 pm


-----------------------------------
ok that sounds terrific.  Cross platform code?  Someone write a tutorial on using cross platform libraries instead of the API.  

It would stop noobs like me from using the API, :D

-----------------------------------
bugzpodder
Sat Sep 16, 2006 8:06 pm


-----------------------------------
First off...

Being insane is not a bad thing.  ;)

Second, I view this from the perspective of Win32 API knowledge being largely useless.  There is a lot to be learned out there that is not tied to a proprietary operating system that moves at a snail's pace technologically and is tied to a massive company in slow bureaucratic decline.

tell that to the developers that tries target their software at 90% of the world's PCs

-----------------------------------
wtd
Sun Sep 17, 2006 7:29 am


-----------------------------------
How many people here do you suppose are writing commercial apps that have to be marketed to hundreds of millions of computer users?

-----------------------------------
bugzpodder
Mon Sep 18, 2006 2:08 pm


-----------------------------------
while i agree the win32 api has little real value, i believe the .net framework might be worth the time to look into for someone on this board for some windows specific developing
