Thread: cannot convert from 'char [256]' to 'unsigned char [256]'

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    13

    cannot convert from 'char [256]' to 'unsigned char [256]'

    I been looking for help on this on google and other places.

    here is my code

    Mario.cpp(187) : error C2440: 'initializing' : cannot convert from 'char [256]' to 'unsigned char [256]'

    Code:
    // get path to 'Program Files' folder
    char lpszPath[MAX_PATH] = {0};
    SHGetSpecialFolderPath( NULL, lpszPath, CSIDL_PROGRAM_FILES, 0);
    char installpath[256];
    sprintf(installpath, "%s\\Game\\Mario.exe", lpszPath);
    
    
    HKEY hKey2;
    unsigned char omg[256] = installpath;   //this line causes compile error
    Im trying to do registry thing for my game.
    Mouse

  2. #2
    Novice Programmer Pyroteh's Avatar
    Join Date
    Jan 2005
    Location
    Alaska
    Posts
    82
    hmm... maybe this might help....

    Compiler Error C2440

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    13
    that link dont help at all.

    Quote Originally Posted by Pyroteh
    hmm... maybe this might help....

    Compiler Error C2440
    Mouse

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Use strcpy() if you want to make a copy of a C-Style string.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    13
    I tried strcpy() I get errors.
    Mouse

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> I tried strcpy() I get errors.

    then post your code and the errors.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I would think you would get warnings with strcpy(), not errors. Unless you have good reason, don't use an unsigned char array. If you need to, use strlen() and memcpy().

    As a side note, since we're in C++ land, you can always use strings.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Need Help Please
    By YouShallNotPass in forum C++ Programming
    Replies: 3
    Last Post: 08-22-2006, 11:22 AM
  3. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  4. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM
  5. ANY BODY WILLING TO HELP ME WITH Microsoft Visual C++
    By BiG pImPiN fOoL in forum C++ Programming
    Replies: 12
    Last Post: 11-04-2001, 06:03 PM