Error C2664 Conversion Requires Reinterpret_cast C-style Cast Or Function-style Cast
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up C code in C++ compiler up vote 2 down vote favorite 2 I have following code, it's code from tomcrypto's manual and it won't work on MS VC++ 2008 EE. Any help? Also can I ask replace char* by std::string object? int main(void) { hash_state md; unsigned char *in = "hello world", out[16]; /* setup the hash */ md5_init(&md); /* add the message */ md5_process(&md, in, strlen(in)); /* get the hash in out[0..15] */ md5_done(&md, out); return 0; } Errors: \main.cpp(7) : error C2440: 'initializing' : cannot convert from 'const char [12]' to 'unsigned char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast .\main.cpp(11) : error C2664: 'strlen' : cannot convert parameter 1 from 'unsigned char *' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast EDIT: Now code looks like: int main(void) { register_hash(&md5_desc); hash_state md; char* p = "hello wordl"; unsigned char *in = reinterpret_cast
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: error: Types pointed to http://stackoverflow.com/questions/5717510/c-code-in-c-compiler are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Visual Studio Languages , Windows Desktop Development > Visual C++ Question 0 Sign in to vote I got a sample code from MSDN (http://msdn2.microsoft.com/en-us/library/aa382363.aspx) I generate a Win32 console application project in VisualStudio 2005 and copy the code into my main.cpp. But when I https://social.msdn.microsoft.com/Forums/en-US/9dd94009-890d-4fcc-b56b-294f42abb3aa/error-types-pointed-to-are-unrelated-conversion-requires-reinterpretcast-cstyle-cast-or?forum=vcgeneral compiled it, I got the following errors: 1>Compiling...1>main.cpp1>.\main.cpp(55) : error C2664: 'CertOpenSystemStoreW' : cannot convert parameter 2 from 'char [256]' to 'LPCWSTR'1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast1>.\main.cpp(103) : error C2664: 'CertGetNameStringW' : cannot convert parameter 5 from 'char [256]' to 'LPWSTR'1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast1>.\main.cpp(317) : error C3861: '_ftprintf': identifier not found1>.\main.cpp(318) : error C3861: '_ftprintf': identifier not found1>.\main.cpp(319) : error C3861: '_ftprintf': identifier not found1>.\main.cpp(320) : error C3861: '_ftprintf': identifier not found1>Build log was saved at "file://d:\C++\cryptoAPI\Creating a Key Container and Generating\Creating a Key Container and Generating\Debug\BuildLog.htm"1>Creating a Key Container and Generating - 6 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Does anyone have some ideas? thank you in advance! this is the source code: #include
files into their proper places (I specify that http://www.cplusplus.com/forum/windows/53565/ because it gave me a lot of trouble- specifically, I put in gl.h, glaux.h, and glut.h. It wouldn't have been so bad if I hadn't gone on a wild goose chase through the Internet hunting down the wrong file.) I am trying to run Lesson 2 error c2664 of NeHe's OpenGL tutorial, but I'm getting odd error messages. No idea what's wrong. Also, I'm sorry if this is the wrong forum website to do this. It just seemed convenient to go here, and I figured someone might recognize what was wrong. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
1 1>Compiling... 1>nehelesson2.cpp error c2664 conversion 1>c:\users\noahpocalypse\documents\visual studio 2008\projects\prototype\prototype\nehelesson2.cpp(87) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [29]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\users\noahpocalypse\documents\visual studio 2008\projects\prototype\prototype\nehelesson2.cpp(92) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [34]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\users\noahpocalypse\documents\visual studio 2008\projects\prototype\prototype\nehelesson2.cpp(99) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [31]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\users\noahpocalypse\documents\visual studio 2008\projects\prototype\prototype\nehelesson2.cpp(105) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [24]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\users\noahpocalypse\documents\visual studio 2008\projects\prototype\prototype\nehelesson2.cpp(109) : error C2664: 'UnregisterClassW' : cannot convert par