Mysterious Error from simple code...

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//mrs decompiler
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <fstream>
using namespace std;

int main()
{
	SetConsoleTitle("A3 Mrs Decompile");
	
	string option;
	do {
		system("bin\\f.bat");
		cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
		cout << "\t+-----------------------------------------+\n";
		cout << "\t|Option - Effect                          |\n";
		cout << "\t+-----------------------------------------+\n";
		cout << "\t|   c     -  Compiles into a system.mrs   |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   d     -  Decompiles system.mrs        |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   info  -  creates a readme.txt         |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   help  -  creates help.txt             |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   exit  -   exit mrs compiler/decompiler|\n";
		
		
		HANDLE font;
		font = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleAttribute(font,FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE);

		cout << "\t\t Enter your option: ";

		cin >> option;

		if (option=="d")
		{
			cout << "\n\n";
			system("bin\\mrs.exe d mrs\\system.mrs");
			cout << "\n system.mrs was decompiled\n";
			system("pause");
		}
		else if (option=="c")
		{
			cout << "\n\n";
			system("bin\\mrs.exe c mrs\\system");
			system("pause");
		}
		else if (option=="info")
		{
			ofstream readme;
			readme.open("Readme.txt");
			readme << "A3 Mrs Decompiler/Compiler \n\n";
			readme << "Website : Home \n\n";
			readme << "Author: Keithrwilcox@hotmail.com / Rwkeith \n\n";
			readme << "-Keith \n";
			readme.close();
			cout << "\n\nReadme was Created...";
			system("pause");
		}
		else if (option=="help")
		{
			ofstream help;
			help.open("help.txt");
			help << "How to use: \n\n";
			help << "\tHow to compile: \n";
			help << "\t\tTake the folder that you want to compile into system.mrs \n";
			help << "\t\tand put it into the mrs folder, and name the folder you want to convert \n";
			help << "\t\tto \ 'system\' and then run A3MD and type \ 'c\' as your option\n\n";
			help << "\tHow to decompile: \n";
			help << "\tTake the system.mrs and put it into the mrs folder, then run \n";
			help << "\t\tA3MD and type \ 'd\' as your option\n\n";
			help.close();
			cout << "\n\nhelp.txt was created...";
			system("pause");
		}
		else if (option=="exit")
		{
			option = "exit";
		}
		else
		{
			cout << "\n\nThe option you entered was invalid...";
			sytem("pause");
		}

	} while (option!= "exit");
return 0;
}


After debugging:
1>------ Build started: Project: MrsDecompiler, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(10) : error C2664: 'SetConsoleTitleW' : cannot convert parameter 1 from 'const char [17]' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(32) : error C3861: 'SetConsoleAttribute': identifier not found
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(36) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        c:\program files\microsoft visual studio 9.0\vc\include\istream(1144): could be 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,signed char *)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]

1>        while trying to match the argument list '(std::istream, std::string)'
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(38) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        could be 'built-in C++ operator==(const char [2], const char [2])'
1>        c:\program files\microsoft sdks\windows\v6.0a\include\guiddef.h(192): or       'int operator ==(const GUID &,const GUID &)'
1>        while trying to match the argument list '(std::string, const char [2])'
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(45) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        could be 'built-in C++ operator==(const char [2], const char [2])'
1>        c:\program files\microsoft sdks\windows\v6.0a\include\guiddef.h(192): or       'int operator ==(const GUID &,const GUID &)'
1>        while trying to match the argument list '(std::string, const char [2])'
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(51) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        could be 'built-in C++ operator==(const char [5], const char [5])'
1>        c:\program files\microsoft sdks\windows\v6.0a\include\guiddef.h(192): or       'int operator ==(const GUID &,const GUID &)'
1>        while trying to match the argument list '(std::string, const char [5])'
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(63) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        could be 'built-in C++ operator==(const char [5], const char [5])'
1>        c:\program files\microsoft sdks\windows\v6.0a\include\guiddef.h(192): or       'int operator ==(const GUID &,const GUID &)'
1>        while trying to match the argument list '(std::string, const char [5])'
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(71) : warning C4129: ' ' : unrecognized character escape sequence
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(71) : warning C4129: ' ' : unrecognized character escape sequence
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(74) : warning C4129: ' ' : unrecognized character escape sequence
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(79) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        could be 'built-in C++ operator==(const char [5], const char [5])'
1>        c:\program files\microsoft sdks\windows\v6.0a\include\guiddef.h(192): or       'int operator ==(const GUID &,const GUID &)'
1>        while trying to match the argument list '(std::string, const char [5])'
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(86) : error C3861: 'sytem': identifier not found
1>c:\visual studio 2008\projects\mrsdecompiler\mrsdecompiler\main.cpp(89) : error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        could be 'built-in C++ operator!=(const char [5], const char [5])'
1>        c:\program files\microsoft sdks\windows\v6.0a\include\guiddef.h(197): or       'int operator !=(const GUID &,const GUID &)'
1>        while trying to match the argument list '(std::string, const char [5])'
1>Build log was saved at "file://c:\Visual Studio 2008\Projects\MrsDecompiler\MrsDecompiler\Debug\BuildLog.htm"
1>MrsDecompiler - 10 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



As a beginner, this leaves me dumbfounded.
Last edited on
First off, please use code tags (not output) so we can read the code better ;)

Second, start with one error at a time. When you see a big mess of output like this you can get
discouraged quickly. Go down the list, read the error codes. For example your first concern is:
error C2664: 'SetConsoleTitleW' : cannot convert parameter 1 from 'const char [17]' to 'LPCWSTR'


Lookup C2664 on google if you can't figure out what went wrong.

I'm not saying this to be annoying, but this is how we all learn ;)
Thanks for the advice. I'll try to resolve these errors >.<.

Edit: I fixed the code tags.
Last edited on
Dont make a program that makes readme.txt. People obviously want to read it before using the program.
I fixed all of the errors. Here is the revised code if anyone would like to see it. =)

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//mrs decompiler
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <fstream>
#include <string>
using namespace std;

int main()
{
	SetConsoleTitle("A3 Mrs Decompile");
	
	string option;
	do {
		system("bin\\f.bat");
		cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
		cout << "\t+-----------------------------------------+\n";
		cout << "\t|Option - Effect                          |\n";
		cout << "\t+-----------------------------------------+\n";
		cout << "\t|   c     -  Compiles into a system.mrs   |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   d     -  Decompiles system.mrs        |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   info  -  creates a readme.txt         |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   help  -  creates help.txt             |\n";
		cout << "\t|                                         |\n";
		cout << "\t|   exit  -   exit mrs compiler/decompiler|\n";
		
		
		HANDLE font;
		font = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleTextAttribute(font,FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE);

		cout << "\t\t Enter your option: ";

		cin >> option;

		if (option=="d")
		{
			cout << "\n\n";
			system("bin\\mrs.exe d mrs\\system.mrs");
			cout << "\n system.mrs was decompiled\n";
			system("pause");
		}
		else if (option=="c")
		{
			cout << "\n\n";
			system("bin\\mrs.exe c mrs\\system");
			system("pause");
		}
		else if (option=="info")
		{
			ofstream readme;
			readme.open("Readme.txt");
			readme << "A3 Mrs Decompiler/Compiler \n\n";
			readme << "Website : Home \n\n";
			readme << "Author: Keithrwilcox@hotmail.com / Rwkeith \n\n";
			readme << "-Keith \n";
			readme.close();
			cout << "\n\nReadme was Created...";
			system("pause");
		}
		else if (option=="help")
		{
			ofstream help;
			help.open("help.txt");
			help << "How to use: \n\n";
			help << "\tHow to compile: \n";
			help << "\t\tTake the folder that you want to compile into system.mrs \n";
			help << "\t\tand put it into the mrs folder, and name the folder you want to convert \n";
			help << "\t\tto  system and then run A3MD and type   as your option\n\n";
			help << "\tHow to decompile: \n";
			help << "\tTake the system.mrs and put it into the mrs folder, then run \n";
			help << "\t\tA3MD and type  as your option\n\n";
			help.close();
			cout << "\n\nhelp.txt was created...";
			system("pause");
		}
		else if (option=="exit")
		{
			option = "exit";
		}
		else
		{
			cout << "\n\nThe option you entered was invalid...";
			system("pause");
		}

	} while (option!= "exit");
return 0;
}


Topic archived. No new replies allowed.