Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sex up an array?
Index -> Programming, C++ -> C++ Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Justin_




PostPosted: Wed Aug 16, 2006 12:47 am   Post subject: 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.
Sponsor
Sponsor
Sponsor
sponsor
Justin_




PostPosted: Wed Aug 16, 2006 12:56 am   Post subject: (No subject)

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]




PostPosted: Wed Aug 16, 2006 1:25 am   Post subject: (No subject)

c++:
#include <vector> //part of the STL
Justin_




PostPosted: Wed Aug 16, 2006 1:40 am   Post subject: (No subject)

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




PostPosted: Wed Aug 16, 2006 3:45 am   Post subject: (No subject)

Use STL algorithms.

code:
vector<int> foo(10);
// initialize

int *bar = new int[foo.size()];

copy(foo.begin(), foo.end(), bar);
Justin_




PostPosted: Wed Aug 16, 2006 4:04 am   Post subject: (No subject)

Clever... Really, I wish I had devoted more time into the STL.
Justin_




PostPosted: Wed Aug 16, 2006 4:15 am   Post subject: (No subject)

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




PostPosted: Wed Aug 16, 2006 11:27 am   Post subject: (No subject)

http://en.wikipedia.org/wiki/Windows_Template_Library
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Wed Aug 16, 2006 11:29 am   Post subject: (No subject)

http://en.wikipedia.org/wiki/Windows_Template_Library
Justin_




PostPosted: Wed Aug 16, 2006 12:30 pm   Post subject: (No subject)

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




PostPosted: Wed Aug 16, 2006 1:13 pm   Post subject: (No subject)

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




PostPosted: Wed Aug 16, 2006 2:11 pm   Post subject: (No subject)

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_




PostPosted: Wed Aug 16, 2006 2:29 pm   Post subject: (No subject)

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




PostPosted: Wed Aug 16, 2006 5:39 pm   Post subject: (No subject)

First off...

Being insane is not a bad thing. Wink

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_




PostPosted: Wed Aug 16, 2006 5:43 pm   Post subject: (No subject)

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?
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 22 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: