c++ - 我的代码似乎什么都不做

标签 c++

<分区>

什么都不做,当我调用 gets() 时它甚至不让我输入,甚至我的 IDE 都声称“声明无效”。

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int main()
{
char userluv[800], fuusd[800], orig[800], key [51], priv [21];
int tempfussd[800], kint, pint, tint[5], c, lame;

//get the basic info
cout << "key? ";
cin >> key;
cout << "Second key? ";
cin >> priv;
cout << "Your lovely text?:\n";
gets(userluv);

for(c=0; c<=key[c]; c++){
    kint += key[c];
}
for(c=0; c<=priv[c]; c++){
    pint += priv[c];
}

//do stuff to your key
tint[0] = strlen(key) + strlen(priv);
tint[1] = tint[0] * tint[0];

//string to int then do stuff
    for(c=0; c<=userluv[c]; c++){
    tempfussd[c] = userluv[c];
    tempfussd[c] + kint;
    tempfussd[c] * pint;
    tempfussd[c] * tint[1];
}

    cout << "\n" << tempfussd[c] << "\n";

return 0;
}

最佳答案

这三行是​​没有效果的语句:

tempfussd[c] + kint;
tempfussd[c] * pint;
tempfussd[c] * tint[1];

您可能在 +* 之后省略了 =

上面标识的语句出现在循环中:

for(c=0; c<=userluv[c]; c++){
    tempfussd[c] = userluv[c];
    tempfussd[c] + kint;
    tempfussd[c] * pint;
    tempfussd[c] * tint[1];
}

如果(如评论所暗示的那样)+=*= 是正确的,您可以通过编写来简化事情:

for (c = 0; c <= userluv[c]; c++)
    tempfussd[c] = (userluv[c] + kint) * pint * tint[1];

关于c++ - 我的代码似乎什么都不做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13282304/

相关文章:

C++函数指针问题

C++是否有任何简单的可嵌入到您的应用程序库中的文本文件版本控制和修订控制?

c++ - 对空的用户定义构造函数如何初始化非静态非 POD 成员变量感到困惑

c++ - 固定宽度整数类型是否保证是标准内置类型的 typedef?

c++ - Boost.Python 与签名左值不匹配

c++ - 循环函数调用不正确循环! (C++)

c++ - C++中哪些情况会用到clone,如何使用?

c++ - 写入文本文件,二进制与 ascii

C++枚举数据结构

python - Opencv全向标定校正