为什么以下代码使用Dev-C++编译器而不是Visual Studio编译?
任何的想法?这是代码:
#include<stdio.h>
main(){
int n,i;
scanf("%d",&n);
int arr[n];
for(i= 0 ; i <n ; i++)
{
//Do something with the array
}
fflush(stdin);
getchar();
}
Run Code Online (Sandbox Code Playgroud)
以下是错误:
我有以下代码顺序搜索在Visual C++中完美运行
#include<iostream>
using namespace std;
int seqSearch(int list[], int length, int item)
{
int index = length-1;
if (index < 0)
return -1;
if (list[index] == item)
return (index);
else seqSearch(list, index, item);
} // end seqSearch
int main ()
{
int const length = 10;
int item;
int list[10] = { 2, 3, 4, 5, 20, 40, 80, 45, 99, 0};
cout << "Please enter the value to be searched: ";
cin>> item;
if (seqSearch(list, length, item) == …Run Code Online (Sandbox Code Playgroud) 我刚刚学习了 C++,我正在尝试使用 windows.h 标头编写一个程序。我正在使用 Dev-C++ 编译器,但遇到三个错误,但找不到解决方案。
这些是错误:
无法打开输出文件 filename.exe:权限被拒绝
[错误] ld 返回 1 目标“filename.exe”的退出状态配方失败
这是我的代码:
#include <windows.h&$62
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
HWND textfield;
/* This is where all the input to the window goes to */
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
switch(Message) {
case WM_CREATE:
CreateWindow("STATIC",
"DocJoin Document Combiner",
WS_VISIBLE | WS_CHILD | WS_BORDER,
20,20,300,25,
hwnd,NULL,NULL,NULL);
break;
/* Upon destruction, tell the main thread to stop */ …Run Code Online (Sandbox Code Playgroud) AS在函数decleration中,需要三件事,即返回值类型.功能名称.(参数类型).但参数名称不是必需的.那么为什么这个程序生成错误,当我arr[][maxCols]从函数prototype(void readMatrix(int arr[][maxCols] );)中删除参数name ()
简单来说.
void readMatrix(int arr[][maxCols] ); // fine and no error.
void readMatrix(int); // but this generates error when argument name is not mentioned in function prototype.
Run Code Online (Sandbox Code Playgroud) 我想在 DEv C++ 5.9 中包含数组,但它给出了一个错误:
32 2 c:\program files (x86)\dev-cpp\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++\bits\c++0x_warning.h [Error] #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
Run Code Online (Sandbox Code Playgroud)
这是因为我使用的 DEV-C++ 版本还是我的电脑 IOS?我使用了其他版本的 DEV C++,但由于我的计算机上装有 Windows 8,因此它们无法解决此问题,因此我需要使用此版本的 DEV C++。任何帮助表示赞赏。
谢谢
我已经用 Java 和最近的 C++ 开发程序几年了。一切都很顺利,直到几个月前,我在编辑器中使用的字体突然在每个字母之间出现了巨大的空间,几乎无法阅读。对于 Java,我使用了 NetBeans IDE。现在在我的代码中,我使用了 Papyrus 字体,我将其修改为等宽字体。给我的评论手写的外观,同时仍然可用。
几个月前,我的评论间距突然看起来每个字符之间都有一个空格。当我修改字体时,我认为这是我的错,我只是换了一种不同的字体。工作正常,如果少一点乐趣。
现在,当我在学习 C++ 课程时,我的导师推荐了 Dev C++ IDE。我知道它很旧,但这是我被告知要使用的。现在我在这里遇到同样的问题,只有所有字体。有人知道怎么修这个东西吗?
截屏:
注意"len = strlen(s);"行中代码的差异.在代码1中:它在"strcpy(str,s)"之前写入,在代码2之后写入.它有什么不同?我在Dev C++中运行我的代码,我得到不同的输出.在两种情况下输出都不一样吗?
代码1:
#include <iostream>
#include <string.h>
using namespace std;
class String{
private:
char str[];
int len;
public:
String()
{
cout << "Default Constructor" << endl;
len = 0;
strcpy(str,"");
}
String(char s[])
{
cout << "parameterised constructor" << endl;
len = strlen(s);
strcpy(str,s);
}
void print()
{
cout << str << " len = " << this->len << " strlen = " << strlen(str) << endl;
}
};
int main()
{
String str2("Hello World");
str2.print();
return 0; …Run Code Online (Sandbox Code Playgroud) 三角形的面积在输出中显示为零,这是为什么?
我做错了什么??
#include <iostream>
using namespace std;
int main() {
int Base, Height, Area;
// >>> Is anything wrong with the formula??
Area = (0.5) * Height * Base;
cout << "To find the Area of Triangle" << endl << endl;
// Base
cout << "Enter Base length:";
cin >> Base;
cout << endl;
// Height
cout << "Enter Height length";
cin >> Height;
cout << endl << endl;
cout << "Your Base Length is:" << Base << endl;
cout …Run Code Online (Sandbox Code Playgroud) 我们可以通过argvC++ 中的代码访问命令行参数,我知道。
但问题是,如果一个参数包含空格,那么我的程序就像有两个参数一样工作。
例如,如果参数是foo bar,我的程序会看到两个参数(foo和bar)。
这是我的代码:
string strParameter = string(argv[1]);
所以我该怎么做?
我正在尝试在 dev-c++ 中打印出一个心形符号。
打印出我写下的一颗心
#include <iostream>
using namespace std;
int main()
{
char heart = 3;
cout << "Heart = " << heart << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,它不会在我的计算机上打印出心形。我还将 ANSI 设置更改为“是”。我的同学和教授可以看到心形符号,但看不到我:/有人可以帮忙吗?