我是新手编程,并试图改进我的基本倒数计时器。我不知道为什么我会得到这个错误,其他问题是在不同的情况下,因此不适合我的程序。`const char *'到`char'
//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 = -1;
}
else if (progend [5] = "start")
{
cin >> a;
while (a>0) { /* the actual countdown timer*/
Sleep(100);
a = a - 0.1;
cout << a;
}
cout << "Finished!" << ".\n" << "Enter start then enter another number to count down from or enter end to close the program" << ".\n";
}
else
{
cout << "Enter yes or end";
}
}
return 0;
}
任何帮助,将不胜感激。
而'progend [5]'对于字符串''start''来说太短 - 无法终止nul字符 –
“出现此错误” - 请考虑在下次添加* full * eror消息 – codeling