小编Ral*_*one的帖子

未初始化的错误

我需要做些什么来修复程序中未初始化的错误?该程序假设打印一个数字具有的除数,但仍然显示错误,表示变量c未初始化.

/*
/ Name: Ralph Lee Stone
/ Date: 10/10/2013
/ Project: RLStone3_HW_08
/ Description: This program gets a positive value and determines the number of divisors    it has.
*/
#include <iostream>
using namespace std;

int DivisorCount(int x)
{
  int counter = 0;
  for(int c; x < c; c++)
  {
    if (x%c==0)
     counter++;
  }
  return counter;
}
int main()
{
  int x;
  cout << "Please a positive value: ";
  cin >> x;
  cout << x << "has this many divsors: …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
730
查看次数

标签 统计

c++ ×1