SafeCracker program help.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
program:
<pre class="prettyprint // learn.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "safestuff.cpp"




using namespace std;
int main()
{
cout << "Suprise, suprise!" << endl;
cout << "The combination is (once again)" <<endl;
cout << SafeCracker(12)<<endl;
system("pause");
return 0;[/code]
<br/>

safestuff.cpp
<pre class="prettyprint using namespace std;
#ifndef SAFESTUFF_H_INCLUDED
#define SAFESTUFF_H_INCLUDED
string SafeCracker(int SafeID);
#endif // SAFESTUFF_H_INCLUDED[/code]
<br/>

SafeCracker.cpp
<pre class="prettyprint #include <iostream>
using namespace std;
string SafeCracker(in SafeID)
{
return "13-26-16";
}[/code]

error code:
1>------ Build started: Project: learn, Configuration: Debug Win32 ------<br/>
1> safestuff.cpp<br/>
1>c:usersjonbecherdocumentsvisual studio 2012projectslearnlearnsafestuff.cpp(6): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add #include "stdafx.h" to your source?<br/>
1> learn.cpp<br/>
1>c:usersjonbecherdocumentsvisual studio 2012projectslearnlearnlearn.cpp(16): error C2679: binary << : no operator found which takes a right-hand operand of type std::string (or there is no acceptable conversion)<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(695): could be std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,const char *)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(742): or std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,char)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(780): or std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,const char *)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(827): or std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,char)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(953): or std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,const signed char *)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(960): or std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,signed char)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(967): or std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,const unsigned char *)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(974): or std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,unsigned char)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(984): or std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>,std::string>(std::basic_ostream<_Elem,_Traits>
&&,const _Ty &)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char>,<br/>
1> _Ty=std::string<br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(1101): or std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits>
&,const std::error_code &)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(201): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits>
&(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(207): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits>
&(__cdecl *)(std::basic_ios<_Elem,_Traits> &))<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(214): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl
*)(std::ios_base &))<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(221): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(241): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(275): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(295): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(int)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(320): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned int)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(340): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(360): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned long)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(381): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(401): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(422): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(442): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(462): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(482): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> c:program filesmicrosoft visual studio 11.0vcincludeostream(502): or std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits>
*)<br/>
1> with<br/>
1> [<br/>
1> _Elem=char,<br/>
1> _Traits=std::char_traits<char><br/>
1> ]<br/>
1> while trying to match the argument list (std::ostream, std::string)<br/>
1>c:usersjonbecherdocumentsvisual studio 2012projectslearnlearnlearn.cpp(19): fatal error C1075: end of file found before the left brace { at c:usersjonbecherdocumentsvisual studio 2012projectslearnlearnlearn.cpp(13) was matched<br/>
1> SafeCracker.cpp<br/>
1>c:usersjonbecherdocumentsvisual studio 2012projectslearnlearnsafecracker.cpp(1): warning C4627: #include <iostream>: skipped when looking for precompiled header use<br/>
1> Add directive to stdafx.h or rebuild precompiled header<br/>
1>c:usersjonbecherdocumentsvisual studio 2012projectslearnlearnsafecracker.cpp(7): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add #include "stdafx.h" to your source?<br/>
1> Generating Code...<br/>
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


View the full article
 
Back
Top