所以我刚开始学习使用C++编程,目前我正忙于基本的控制台程序。我想做一个小垃圾邮件程序。下面的代码:C++ for循环“语句无效”警告?
#include <iostream>
#include <string>
using namespace std;
string a;
int b;
void repetition(){
cout << "Please enter the number of time you want the text to be spammed" << endl;
cin >> b;
}
void text(){
cout << "Please enter the text you want to spam." << endl;
cin >> a;
for(;b == 0;){
cout << a << endl;
b - 1;
}
}
int main()
{
cout << "Welcome to your auto-spammer!!" << endl;
repetition();
text();
return 0;
}
我得到一个警告说“语句没有影响”我在20行我想知道为什么,我怎么能解决这个说法。谢谢。
'b - 1;'没有影响:也许'b - = 1;' – 2014-12-02 20:28:02