我知道我不应该使用Dev-C++,但它在学校是强制性的,所以我对此无能为力.
主题是C/C++中的指针,并且在测量整数数组的长度时发生了错误.请参阅以下代码:
// POINTER
# include<iostream>
# include<string.h>
using namespace std;
int main(){
//neues Feld anlegen
int *a = new int[5];
a[0] = 12;
a[1] = 5;
a[2] = 43;
a[3] = -12;
a[4] = 100;
// Feld füllen
for(int i = 0; i<sizeof(a);i++){
cout<<a[i]<<"\n"<<endl;
}
cout<<sizeof(a);
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
sizeof()返回4而不是5 ...任何想法?
我的任务是计算保龄球平均值.我有五名球员,每位球员有三场比赛.我目前有两个循环运行,一个用于播放器,另一个用于游戏号码.我需要在每个循环结束时显示玩家平均值,并且团队在该循环结束时平均.
我修复了我的代码,并用下面的新代码替换了我的旧代码.在我查看每个人的评论等之前,我正在玩它,然后我解决了它.
但是谢谢大家!
#include <iostream>
using namespace std;
int main()
{
//DECLARATIONS
const int PLAYER_NUMBER = 5; //There are five players total
const int GAME_NUMBER = 3; //There are three games total
const int MIN = 0; //Min number
const int MAX = 300; //Max number
double* playerScore; //The players' score of current game
double playerAverage = 0; //The current players' average
double teamAverage = 0; //The teams' average
//INPUT
for (int currentPlayer = 0; currentPlayer < PLAYER_NUMBER; currentPlayer++)
{//Set …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
WItem.h
#include <vector>
#include <string>
typedef struct iteminfo {
int rowid;
char* item;
int type;
int extra;
int objectid;
} item;
class CItem {
public:
void push(int rowid, char* item, int type, int extra, int objectid);
std::vector<iteminfo> data;
};
Run Code Online (Sandbox Code Playgroud)
WItem.cpp
#include "witem.h"
void CItem::push(int rowid, char* item, int type, int extra, int objectid) {
iteminfo* temp = new iteminfo;
temp->rowid = rowid;
temp->item = item;
temp->type = type;
temp->extra = extra;
temp->objectid = objectid;
this.data.push_back(temp);
}
Run Code Online (Sandbox Code Playgroud)
我收到这些错误:
我在DevC中使用OpenSSl.我在编程PBKDF时遇到了问题.有人建议我使用名为PKCS5_PBKDF2_HMAC的默认函数.我在网上访问了很多链接,但无法使用它.我的主要代码()代码如下
unsigned char pass[1024]; // passphrase read from stdin
unsigned char salt[1024]; // salt
int iter=1000, keylen=128; // iteration
unsigned char result[1024]; // result
PKCS5_PBKDF2_HMAC (pass, strlen(pass), salt, strlen(salt), iter, EVP_MD(), keylen , result);
Run Code Online (Sandbox Code Playgroud)
我只有两个编译错误,如下所示:
要进行故障排除我检查了头文件并且还验证了我提供了正确的参数并且顺序正确,但我没有解决方案而且我感到困惑.
我想使用"Dev-C++"来编译c ++代码.所以我下载并安装它,并编写以下代码:
#include <iostream.h>
main () {
cout << "124";
}
Run Code Online (Sandbox Code Playgroud)
但是当我编译它时,它说:
在包含自E:/ Dev-Cpp/include/c ++/3.4.2/backward/iostream.h:31的文件中,来自[myfile path]\Untitled1.cpp:1:E:/ Dev-Cpp/include/c ++/3.4.2/backward/backward_warning.h:32:2:warning:#warning此文件至少包含一个已弃用或过时的标头.请考虑使用C++标准第17.4.1.2节中的32个标头之一.示例包括将标头替换为C++包含的标头,或者代替不推荐使用的标头.要禁用此警告,请使用-Wno-deprecated.
看到错误后,我将代码更改为此代码:
#include <iostream>
main () {
cout << "124";
}
Run Code Online (Sandbox Code Playgroud)
但它又说错了.
我在Turbo C++中轻松编译第一个代码,但在Dev-C++中编译...
我能做什么?
我们正在使用一种方法
#define CM_VALUE_1 CM_Method(3001)
Run Code Online (Sandbox Code Playgroud)
CM_Method是在同一文件中定义的方法.
我只想在vc ++中CM_Method(3001)使用打印CM_VALUE_1
这是我的代码:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
main()
{
char a[120];
int b;
cout<<"age : ";
cin>>b;
cout<<"Name : ";
gets(a);
cout<<"Name : "<<a<<endl;
cout<<"age : "<<b;
cout<<endl;
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:年龄:20 //我输入20名称:名称://不要求输入名称.年龄:20按任意键继续...
但是,如果我先使用gets(a),那就没关系.
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
main()
{
char a[120];
int b;
cout<<"Name : ";
gets(a);
cout<<"age : ";
cin>>b;
cout<<"Name : "<<a<<endl;
cout<<"age : "<<b;
cout<<endl;
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:姓名:约翰//我输入约翰.年龄:20 //我打20.
姓名:John年龄:20按任意键继续......
他们怎么了......请帮忙......
为什么"Dev C++"不支持C++中的iostream.h头文件..?如何在Dev C++中包含iostream.h头文件?
在Dev-C++中编译我的程序时
LPCTSTR ClsName = L"BasicApp";
LPCTSTR WndName = L"A Simple Window";
Run Code Online (Sandbox Code Playgroud)
编译中断,但是当我编译我的程序时
LPCTSTR ClsName = "BasicApp";
LPCTSTR WndName = "A Simple Window";
Run Code Online (Sandbox Code Playgroud)
它成功了; 因此,问题是如何以VS ++的'L'方式将unicode-strings传递给Orwell Dev-C++.
我有一个用 C++ 实现邻接矩阵的程序。
这是我的代码-
#include<iostream>
using namespace std;
void addEdge(int * add){
cout<<"Edge added successfully.\n";
*add = 1;
}
int main(){
int vertex;
cout<<"Enter number of vertices in the graph: ";
cin>>vertex;
int adjMat[vertex][vertex];
for(int i=0;i<vertex;i++){
for(int j=0;j<vertex;j++){
adjMat[i][j] = 0;
}
}
cout<<"\n";
cout<<"Add edges (from and to): ";
int from,to;
while(cin>>from>>to){
if((from >= vertex || from < 1) || (to >= vertex || to < 1)){
cout<"Warning: Out of bound index.\n";
}else{
addEdge(&adjMat[--from][--to]);
}
}
cout<<"\n";
for(int i=0;i<vertex;i++){ …Run Code Online (Sandbox Code Playgroud)