标签: dev-c++

C++数据比较警告

我的程序中有一个WORD变量.

WORD hour;
Run Code Online (Sandbox Code Playgroud)

但是当我比较它时

if(hour>=0 && hour<=18)
{
    hour+=6;
}
Run Code Online (Sandbox Code Playgroud)

由于数据类型的范围有限,它将生成警告 [警告]比较始终为真

我使用Dev-C++作为IDE.

c++ dev-c++ data-comparison

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

权限被拒绝错误开发C++

当我尝试在DEV C++中再次编译C代码时,该工具会给出以下错误.如果我尝试在新文件中复制相同的代码它工作正常,但我再次无法编译新代码,需要再次复制到另一个文件.

 Permission denied  ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

c dev-c++

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

在Dev-C++中包含Qt库

我想知道的是如何在Dev-C++中导入Qt库,因此它将提供与QT Creator 2.7.0相同的功能.我知道如何在Dev-C++编译器选项中添加'include'和'libraries'文件夹.

但问题是:我从哪里获取这些库,以便Dev-C++可以提供与Qt Creator 2.7.0完全相同的功能?

有任何想法吗?

c++ windows qt4 dev-c++

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

为什么浮动乘以0.699999而不是0.7

这里x取0.699999而不是0.7,但y取0.5分配.你能告诉我这种行为的确切原因是什么吗?

#include<iostream>
using namespace std;

int main()
{
float x = 0.7;
float y = 0.5;
if (x < 0.7)
{
if (y < 0.5)
   cout<<"2 is right"<<endl;
else 
   cout<<"1 is right"<<endl;
}
else 
   cout<<"0 is right"<<endl; 

cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ floating-point dev-c++ visual-c++

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

有没有办法增加一个角色?

例如,当您使用a增加变量时,执行此操作

for(k=1; k<21; k++)
Run Code Online (Sandbox Code Playgroud)

对?这意味着for序列将重复,直到k为20,那么,有没有办法增加一个字符变量?像a,b,c,d,e,f ......?谢谢.

问题是我想制作一张桌子但是有一个字符和一个字符增加一个.

我没有尝试任何事情,因为我是一名学生,我只是不知道如何做这样的事情,或者是否有任何命令可以做到这一点?

c c++ variables dev-c++

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

rename()不能在使用Dev C++编译的C程序中工作

我想在C中编写一个可以在MS Win 7环境(NTFS文件系统)下重命名多个文件的程序.因此,这个rename()功能似乎是一个自然的选择.但是,当我在Dev-C++中编写以下内容(但将源文件命名为.c)时:

rename(name1, name2);
Run Code Online (Sandbox Code Playgroud)

编译文件给我错误:

[Error] called object 'rename' is not a function
Run Code Online (Sandbox Code Playgroud)

我已经添加<stdio.h>了标题.有什么我想念的吗?

源代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 50
#define MAX 49

int main()
{
    int *p;
    int i, rename;
    char name1[25], name2[25];

    srand(time(NULL));
    rename = 0;

    p = (int *)malloc(sizeof(int) * N);
    for (i = 0; i < N; i++)
       p[i] = 0;

    for (i = 0; i < MAX; i++) {
        if (p[i] == 0) {
            printf ("** …
Run Code Online (Sandbox Code Playgroud)

c ntfs rename file-rename dev-c++

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

用户名登录绕过密码输入并直接进入else语句

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{

  char username[12] = "admin";
  char password[12] = "admin";


  system("color 9f");
  system("cls");
  login:
  printf("                        ---------------------------------- \n");
  printf("                       |                                  |\n");
  printf("                       |      WELCOME TO OMAR WATER'S     |\n");
  printf("                       |             INVENTORY            |\n");
  printf("                       |              SYSTEM              |\n");
  printf("                       |                                  |\n");
  printf("                        ---------------------------------- \n\n\n");
  printf("Please Log-In...\n\n");
  printf("Username: ");
  scanf("%c", &username);

  if (username == "admin"){
    printf("\nPassword: ");
    scanf("%c", &password);

    if (password == "admin"){
      printf("\n\nWELCOME ", &username);
    }else{
      printf("INVALID PASSWORD");
      getchar();
      system("cls");
      goto login;
    }

  }else { …
Run Code Online (Sandbox Code Playgroud)

c scanf dev-c++

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

函数不返回结果c(在项目文件中)

当我在.c文件中运行此代码时,它可以工作,但是当我为它创建一个项目时,我调用的函数将只返回0.00.为什么?为什么它不能在项目文件中工作?

我正在使用DevC++.

#include<stdio.h>

float mean(int total, int max);

int main(){
    int i,max, total=0;
    int array[max];
    printf("Enter max: ");
    scanf("%d",&max);

    for(i=0; i<max; i++){
        scanf("%d",&array[i]);
        total+=array[i];
    }
    printf("Total: %d\n",total);
    printf("Mean: %.2f",mean(total,max));
    return 0;
}

float mean(int total, int max){
    float ave;
    ave=(float)total/max;

    return ave;
}
Run Code Online (Sandbox Code Playgroud)

c dev-c++

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

c中用户定义函数的冲突类型

经过很长一段时间我在c工作.我必须实现三个功能,包括

  1. 得到一个数字并显示一半

2.获取数字的平方

3.获取两个数字并显示它们的总和和消除.

我正在使用devC++,当我编译代码时,我得到了标题中提到的conflict type if squareInput错误.这里有什么问题:

#include<stdio.h>
#include<conio.h>
int main(){

    float x;
    printf("enter a number\n");
    scanf("%f",&x);

    //TASK 1 : display half of the number 
    pirntf("half of x is = %.3f",x);

    //TASK 2 : square of number 

    squareInput(x); //call square function from here

    // TASK 3 : get two numbers and display both summation and sabtraction

    float num1,num2;   // declare two floating number( floating numbers can hold decimal point numbers
    printf("enter num1 \n");
    scanf("num1 is =%f",&num1);
    printf("enter …
Run Code Online (Sandbox Code Playgroud)

c dev-c++

-1
推荐指数
2
解决办法
76
查看次数

C++ Struct Puzzle无法编译

我有一个来自C++书籍的代码片段:

#include<stdio.h>
#include<stdlib.h>

struct S1
{
    const char *s;
    int i;
    struct S1 *slp;
};

main()
{
    static struct S1 a[]= {{"abcdef", 1, a+1},
                    {"ghijkl", 2, a+2},
                    {"mnopqr", 3, a} };

    struct S1 *p = a;

    printf("a[0].s = %s   p-> = %s   a[2].slp->s = %s \n", a[0].s, p->s, a[2].slp->s);

    for(int i=0; i<3; i++)
    {
        printf("--a[i].i    = %d   ", --a[i].i);
        printf("++a[i].s[3] = %c \n", ++a[i].s[3]);
    }
}
Run Code Online (Sandbox Code Playgroud)

使用Dev C++ v5.11,我无法使用错误代码编译它:

[Error] increment of read-only location '*(a[i].S1::s + 3u)'
Run Code Online (Sandbox Code Playgroud)

由@Corristo评论的解决方案有效.

感谢大家的帮助.我下次会得到更好的IDE和书籍.谢谢,@ Tomaz-Canabrava.

c++ struct dev-c++

-1
推荐指数
1
解决办法
103
查看次数

如何为指针对象c ++赋值

我是新来的,我希望你能解决这个问题,当我在结构或类派生的对象中使用数据类型char进行引用时,我的程序会不断出现错误或遗漏.这是我的来源.提前,谢谢.

 struct test{
    public:

        char cadena[20];
        int num;

   }objeto;

  int main(){

    test *POJ = &objeto;
    (*POJ).cadena="Hello Guys";
    POJ->num=23;
    cout<<(*POJ).cadena<<", "<<POJ->num;

  }
Run Code Online (Sandbox Code Playgroud)

c++ pointers dev-c++

-2
推荐指数
1
解决办法
61
查看次数

这个c代码有什么问题?

#include <stdio.h>

int main() {

    int i = 1;
    int j = -1;

    while(i)
        i++;
    while(-j)
        j--;

    i = i-1;
    j = j+1;

    printf("%d %d\n",i,j);
}
Run Code Online (Sandbox Code Playgroud)

我想知道int的范围!这段代码无法得到正确的答案!但它可以!

#include <stdio.h>

int main() {

    int i = 1;
    int j = -1;

    while(i > 0)
        i++;
    while(j < 0)
        j--;

    i = i-1;
    j = j+1;

    printf("%d %d\n",i,j);
}
Run Code Online (Sandbox Code Playgroud)

我不知道他们之间有什么区别!

c dev-c++

-7
推荐指数
1
解决办法
143
查看次数