我是编程新手,并试图改进我的基本倒数计时器.我不知道为什么我收到此错误,其他问题在不同情况下,因此不适合我的程序.
//countdown timer using while loops, if else, strings and sleep
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
int main ()
{
char progend[5];
float a; /* a will be floating point */
cout << "Enter start the the number you want to count down from" << ".\n";
while (a>-1) { /* the main program is located here */
cin >> progend[5];
if (progend[5] = "end") /* if the user inputs end the program ends */
{
a …Run Code Online (Sandbox Code Playgroud) 我制作了这个程序,当我编译它时没有错误,但程序只是立即关闭,任何答案将不胜感激.
#include <iostream> //Main commands
#include <string> // String commands
#include <windows.h> // Sleep
using namespace std;
int main ()
{
//Declaring variables
float a;
bool end;
std::string input;
end = false; // Making sure program doesn't end instantly
cout << "Enter start then the number you want to count down from." << ".\n";
while (end = false){
cin >> input;
cout << ".\n";
if (input.find("end") != std::string::npos) // Ends the program if user types end
end = true;
else …Run Code Online (Sandbox Code Playgroud)