Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Win32控制台应用程序无法在VS2012 Pro中运行 我用PrATA的C++入门语言和C++来教我自己C++。VS2012 Pro中没有任何错误,程序编译成功,但在Prata 2.5.exe中的0x76ED016E ntdll.dll处出现未处理异常未处理异常:0x00000000:操作成功完成。当我尝试输入C或F作为初始选项时,我不确定哪里出了问题。这个练习只要求我创建一个简单的程序,将华氏温度转换为摄氏温度,但我想我会发现类似的东西很有用,因为我经常使用在线资源来进行转换。如果我有自己的程序,我就不必担心,可以将其扩展到非CLI版本和更多转换选项,如码到米等。任何帮助都将不胜感激 #include "stdafx.h" #include <iostream> // Function Prototypes double convertToF(double); double convertToC(double); int main() { using namespace std; char* convertChoice = "a"; // Initializing because the compiler complained. Used to choose between celsius and fahrenheit. int choiceNumber; // Had issues using the char with switch so created this. double tempNumber; // The actual temperature the user wishes to convert. cout << "Do you wish to convert to [C]elcius or [F]ahrenheit?"; cin >> convertChoice; // IF() compares convertChoice to see if the user selected C for Celsius or F for fahrenheit. Some error catching by using the ELSE. No converting char to lower though in case user enters letter in CAPS. if (convertChoice == "c") { cout << "You chose Celsius. Please enter a temperature in Fahreinheit: " << endl; cin >> tempNumber; choiceNumber = 1; } else if (convertChoice == "f") { cout << "You chose Fahrenheit Please enter a temperature in Celsius: " << endl; cin >> tempNumber; choiceNumber = 2; } else { cout << "You did not choose a valid option." << endl; } // SWITCH() grabs the int (choiceNumber) from the IF(), goes through the function and outputs the result. Ugly way of doing it, but trying to make it work before I make it pretty. switch (choiceNumber) { case 1: double convertedFTemp; convertedFTemp = convertToC(tempNumber); cout << convertedFTemp << endl; break; case 2: double convertedCTemp; convertedCTemp = convertToF(tempNumber); cout << convertedCTemp << endl; break; default: cout << "You did not choose a valid option." << endl; break; } // To make sure the window doesn't close before viewing the converted temp. cin.get(); return 0; } // Function Definitions double convertToF(double x) { double y; y = 1.8 * x + 32.0; return y; } double convertToC(double x) { double y; y = x - 32 / 1.8; return y; }_C++ - Fatal编程技术网

Win32控制台应用程序无法在VS2012 Pro中运行 我用PrATA的C++入门语言和C++来教我自己C++。VS2012 Pro中没有任何错误,程序编译成功,但在Prata 2.5.exe中的0x76ED016E ntdll.dll处出现未处理异常未处理异常:0x00000000:操作成功完成。当我尝试输入C或F作为初始选项时,我不确定哪里出了问题。这个练习只要求我创建一个简单的程序,将华氏温度转换为摄氏温度,但我想我会发现类似的东西很有用,因为我经常使用在线资源来进行转换。如果我有自己的程序,我就不必担心,可以将其扩展到非CLI版本和更多转换选项,如码到米等。任何帮助都将不胜感激 #include "stdafx.h" #include <iostream> // Function Prototypes double convertToF(double); double convertToC(double); int main() { using namespace std; char* convertChoice = "a"; // Initializing because the compiler complained. Used to choose between celsius and fahrenheit. int choiceNumber; // Had issues using the char with switch so created this. double tempNumber; // The actual temperature the user wishes to convert. cout << "Do you wish to convert to [C]elcius or [F]ahrenheit?"; cin >> convertChoice; // IF() compares convertChoice to see if the user selected C for Celsius or F for fahrenheit. Some error catching by using the ELSE. No converting char to lower though in case user enters letter in CAPS. if (convertChoice == "c") { cout << "You chose Celsius. Please enter a temperature in Fahreinheit: " << endl; cin >> tempNumber; choiceNumber = 1; } else if (convertChoice == "f") { cout << "You chose Fahrenheit Please enter a temperature in Celsius: " << endl; cin >> tempNumber; choiceNumber = 2; } else { cout << "You did not choose a valid option." << endl; } // SWITCH() grabs the int (choiceNumber) from the IF(), goes through the function and outputs the result. Ugly way of doing it, but trying to make it work before I make it pretty. switch (choiceNumber) { case 1: double convertedFTemp; convertedFTemp = convertToC(tempNumber); cout << convertedFTemp << endl; break; case 2: double convertedCTemp; convertedCTemp = convertToF(tempNumber); cout << convertedCTemp << endl; break; default: cout << "You did not choose a valid option." << endl; break; } // To make sure the window doesn't close before viewing the converted temp. cin.get(); return 0; } // Function Definitions double convertToF(double x) { double y; y = 1.8 * x + 32.0; return y; } double convertToC(double x) { double y; y = x - 32 / 1.8; return y; }

Win32控制台应用程序无法在VS2012 Pro中运行 我用PrATA的C++入门语言和C++来教我自己C++。VS2012 Pro中没有任何错误,程序编译成功,但在Prata 2.5.exe中的0x76ED016E ntdll.dll处出现未处理异常未处理异常:0x00000000:操作成功完成。当我尝试输入C或F作为初始选项时,我不确定哪里出了问题。这个练习只要求我创建一个简单的程序,将华氏温度转换为摄氏温度,但我想我会发现类似的东西很有用,因为我经常使用在线资源来进行转换。如果我有自己的程序,我就不必担心,可以将其扩展到非CLI版本和更多转换选项,如码到米等。任何帮助都将不胜感激 #include "stdafx.h" #include <iostream> // Function Prototypes double convertToF(double); double convertToC(double); int main() { using namespace std; char* convertChoice = "a"; // Initializing because the compiler complained. Used to choose between celsius and fahrenheit. int choiceNumber; // Had issues using the char with switch so created this. double tempNumber; // The actual temperature the user wishes to convert. cout << "Do you wish to convert to [C]elcius or [F]ahrenheit?"; cin >> convertChoice; // IF() compares convertChoice to see if the user selected C for Celsius or F for fahrenheit. Some error catching by using the ELSE. No converting char to lower though in case user enters letter in CAPS. if (convertChoice == "c") { cout << "You chose Celsius. Please enter a temperature in Fahreinheit: " << endl; cin >> tempNumber; choiceNumber = 1; } else if (convertChoice == "f") { cout << "You chose Fahrenheit Please enter a temperature in Celsius: " << endl; cin >> tempNumber; choiceNumber = 2; } else { cout << "You did not choose a valid option." << endl; } // SWITCH() grabs the int (choiceNumber) from the IF(), goes through the function and outputs the result. Ugly way of doing it, but trying to make it work before I make it pretty. switch (choiceNumber) { case 1: double convertedFTemp; convertedFTemp = convertToC(tempNumber); cout << convertedFTemp << endl; break; case 2: double convertedCTemp; convertedCTemp = convertToF(tempNumber); cout << convertedCTemp << endl; break; default: cout << "You did not choose a valid option." << endl; break; } // To make sure the window doesn't close before viewing the converted temp. cin.get(); return 0; } // Function Definitions double convertToF(double x) { double y; y = 1.8 * x + 32.0; return y; } double convertToC(double x) { double y; y = x - 32 / 1.8; return y; },c++,C++,我也不知道我是否一切都对。即,函数中的公式以及开关的顺序。请不要纠正这一点,一旦这该死的东西编译好,我会自己弄清楚的 请参考评论中的经验法则。您使用的是char*,但没有足够的细节知识来正确使用它。使用std::string,它将完全满足您的需要 供将来参考:带有字符* 你需要分配内存 您需要使用strcmp进行比较 你需要自己注意长度 你需要释放内存 对于初学者来说,这是很多。使用 别忘了 #include <string> 请参考评论中的经验法则。您使用的是char*,但没有足

我也不知道我是否一切都对。即,函数中的公式以及开关的顺序。请不要纠正这一点,一旦这该死的东西编译好,我会自己弄清楚的

请参考评论中的经验法则。您使用的是char*,但没有足够的细节知识来正确使用它。使用std::string,它将完全满足您的需要

供将来参考:带有字符*

你需要分配内存 您需要使用strcmp进行比较 你需要自己注意长度 你需要释放内存 对于初学者来说,这是很多。使用

别忘了

#include <string>

请参考评论中的经验法则。您使用的是char*,但没有足够的细节知识来正确使用它。使用std::string,它将完全满足您的需要

供将来参考:带有字符*

你需要分配内存 您需要使用strcmp进行比较 你需要自己注意长度 你需要释放内存 对于初学者来说,这是很多。使用

别忘了

#include <string>

这不是C++ + CLI,它是普通C++的好东西。请确保从C++项目中选择Win32控制台应用程序。如果它仍然没有编译,请发布编译错误。作为一个经验法则:如果你在C++程序中使用char *,你就有一个bug。请改用std::string。对不起。我想说得具体一些,所以当我说CLI时,我指的是通用命令行界面。忘了我可以称之为Win32控制台应用程序。好的,那么错误是什么?你说它不会编译。一定有编译器错误。我的初始标题是错误的。它确实编译了,但在VS2012中调试时给了我一个错误。我更新了我的问题的标题和正文,这不是C++ + CLI,它是C++的好东西。请确保从C++项目中选择Win32控制台应用程序。如果它仍然没有编译,请发布编译错误。作为一个经验法则:如果你在C++程序中使用char *,你就有一个bug。请改用std::string。对不起。我想说得具体一些,所以当我说CLI时,我指的是通用命令行界面。忘了我可以称之为Win32控制台应用程序。好的,那么错误是什么?你说它不会编译。一定有编译器错误。我的初始标题是错误的。它确实编译了,但在VS2012中调试时给了我一个错误。我更新了我的问题的标题和主体以反映。哦,包括!我很困惑,为什么尝试将convertChoice设置为String不起作用。VS2012没有暗示这一点。谢谢我想,因为我没有遵循char*的步骤,这就是程序崩溃的原因?我添加了include,并将类型更改为string,它可以正常工作。也感谢您的耐心和对char*.Ohhh,an include的解释!我很困惑,为什么尝试将convertChoice设置为String不起作用。VS2012没有暗示这一点。谢谢我想,因为我没有遵循char*的步骤,这就是程序崩溃的原因?我添加了include,并将类型更改为string,它可以正常工作。也感谢您的耐心和对char*的解释。