array<unsigned char>^ vs char[ ]

This is a discussion on array<unsigned char>^ vs char[ ] within the C++ Programming forums, part of the General Programming Boards category; Hey guys, I have started exploring some programming concepts on my own,and in particular some that are special to the ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Location
    Knoxville, Tennessee, United States
    Posts
    20

    array<unsigned char>^ vs char[ ]

    Hey guys, I have started exploring some programming concepts on my own,and in particular some that are special to the windows API. I am trying to use the function shown below as part of my class constructor. My plan is to create a "payload" which will be used later in my AVL tree class.

    Code:
    //constructor
    payload::payload(string clear){}
    Code:
    //mentioned function array<unsigned char>^ ComputeHash(
    	array<unsigned char>^ buffer
    )
    The problem is, I am having trouble finding good materiel that explains exactly what a array<unsigned char>^ really is, and as you can see, I want my constructor to take a string as an argument, but once again the function takes an array<unsigned char>^.

    I need someone to help explain what a array<unsigned char>^ exactly is , and how I can work between them with char[] and strings.

    Thanks a ton guys!

    PS: Here is the reference im looking at ComputeHash Method (Byte[])

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,662
    The problem is that the ComputeHash function isn't C++! It's a new Microsoft-specific language called C++/CLI, which is a different beast. So unless you plan on learning that (in which case this would be more suited for the Tech Board), I suggest you avoid that function and anything connected to the .NET Framework.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Location
    Knoxville, Tennessee, United States
    Posts
    20
    I see, so what would be the best way then to calculate md5 hashes using a C++ windows library? I was stumbling through msdn and that is what happened upon.

    So the next question I pose, so I wasn't ignorant about a C++ feature for not remembering the array<unsigned char>^ type? That is a type that exists only in there c++/CLI language?

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,662
    There is no standard function for calculating md5 hashes, unfortunately. You may want to search the web for some implementation.
    Yep, this type only exists in C++/CLI. You can see that by looking at the "^", which is basically a "managed reference."
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Oct 2010
    Location
    Knoxville, Tennessee, United States
    Posts
    20
    I see, I will look around for a third party library then, I was trying to use Microsoft libs were possible. I have a final question, does the data type array<unsigned char> with out the carrot exists at all in C++ or in a MS library as #define? If it doesn't exists that is actually encouraging to me as it is one less thing to understand.

    PS: Thanks for the information btw!

  6. #6
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    Quote Originally Posted by jlangfo5 View Post
    I see, I will look around for a third party library then, I was trying to use Microsoft libs were possible. I have a final question, does the data type array<unsigned char> with out the carrot exists at all in C++ or in a MS library as #define? If it doesn't exists that is actually encouraging to me as it is one less thing to understand.

    PS: Thanks for the information btw!
    It does exist in the new standard, which is a different thing - a fixed-length array (you need to specify one template parameter more).
    A C++ equivalent would be std::vector.

    And strings should be passed by const reference:

    Code:
    payload::payload(const std::string& clear){}
    I never put signature, but I decided to make an exception.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,662
    The type does exist ISO C++ too. There is std::array and there is unsigned char.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. uincode char array to array<unsigned char,1>^
    By ripspinner in forum Windows Programming
    Replies: 5
    Last Post: 12-14-2009, 04:41 PM
  2. Replies: 2
    Last Post: 10-06-2009, 09:37 AM
  3. Converting unsigned long array to unsigned char array
    By delvec28 in forum C Programming
    Replies: 2
    Last Post: 09-07-2009, 08:53 PM
  4. cast unsigned char* to (the default) signed char*
    By Mario F. in forum C++ Programming
    Replies: 24
    Last Post: 07-27-2007, 10:41 AM
  5. unsigned char vs signed char and range of values
    By Silvercord in forum C++ Programming
    Replies: 5
    Last Post: 01-22-2003, 12:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21