标签: codeblocks

Boost rename()函数不起作用

编译器在构建时没有抱怨,我的程序说它有效,并创建了文件夹,但文件没有移动.我究竟做错了什么?

#include <iostream>
#include <boost/filesystem.hpp>

using namespace std;
using namespace boost::filesystem;

char c = 'c';

bool move(){

 if ((bool) rename("C:\\fldr1" "rawr.txt", "C:\\fldr2" "rared.txt") == (true)){
    return true;
 }
 else{
    return false;
 }

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

    if (argv[1] = (c))
    {
        if (is_directory("C:\\fldr2")){

            if (move){
            cout << "Done 1!" << endl;
            }
        }
        else{
            cout << "Dir doesn't exist!" << endl;

            if ((bool)create_directory("C:\\fldr2") == (true)){

                if (move){
                    cout << "Done 2!" << endl;
                }
            }
        }
    } …
Run Code Online (Sandbox Code Playgroud)

c++ boost g++ codeblocks

2
推荐指数
2
解决办法
4690
查看次数

C++ Vector给出了令人难以置信的意外价值

我有这个代码:

std::vector <int> loc;
loc.push_back(cpx);
loc.push_back(cpy);
loc.push_back(play.GetSize().x);
loc.push_back(70);
std::cout<<loc[3];
Run Code Online (Sandbox Code Playgroud)

在我正在制作的游戏中,但即使我打印了loc [2]和loc [3]的值,它们与它们应该完全不同,当我运行此代码时,我得到loc [3]等于70070而不是70.有谁知道如何解决这个问题?

c++ windows vector codeblocks

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

进程返回-1073741819(0xc0000005)代码::块

我对使用Code :: Blocks(版本12.11)进行C语言编程有点新手,这个学期在我的大学开始,但是我管理着.

我最近在课堂上学到了关于指针,内存分配和动态数组(没有一个是我的强项),我将它们合并到我的程序中(并编译)

现在问题出现在我运行程序并进入菜单 - >添加产品时,程序在我输入价格时终止,并且我收到"流程返回-1073741819(0xc0000005)".我做了一些研究,发现它是一个访问冲突,但我真的不明白如何纠正它.

问候

这是代码:

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

#define maxCharName 64
#define maxCharUserPass 8
#define maxCharId 5

// Product Structure
typedef struct{
    char name[maxCharName];
    char idCode[maxCharId];
    float price;
    float stock;
}product;

// DataBase of Products
typedef struct{
    int sizeT;
    product *array;
} TProducts;

TProducts a;


// Press any Key on the Keyboard to Proceed
void pressKeyToContinue(){
    puts("\n\n\n     Please Press any Key to Continue...");
    getchar();
}

// Start Page
void startPage(){
    puts("\n\n\n                      -- Welcome …
Run Code Online (Sandbox Code Playgroud)

c codeblocks

2
推荐指数
1
解决办法
3万
查看次数

如何折叠全部/展开Codeblocks IDE中的所有函数/方法

在CodeBlocks IDE中,您可以单击函数的左侧并最小化该函数中的所有内容.但是,在诸如IntelliJ的IDE中,我可以按Ctrl+ Shift+ +/ -来展开/折叠所有方法.CodeBlocks中是否有类似的快捷方式?

expand keyboard-shortcuts codeblocks collapse

2
推荐指数
2
解决办法
6811
查看次数

C - 得到角色问题

当我运行以下代码时:

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


int main()
{
    int n;
    char y;

    printf("Message\n");
    fscanf(stdin, "%c", &y);

    printf("Message\n");
    fscanf(stdin, "%c", &y);

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

我明白了:

Message
{enter character}
Message
Run Code Online (Sandbox Code Playgroud)

问题是,即使有2个scanf函数,也不会要求我输入两次字符.输出应该是这样的:

Message
{enter character}
Message
{enter character}
Run Code Online (Sandbox Code Playgroud)



我也有这个问题getc():

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


int main()
{
    int n;
    char y;

    printf("Message\n");
    y=getc(stdin);

    printf("Message\n");
    y=getc(stdin);

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

另外,fflush()没有帮助:

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


int main()
{
    int n;
    char y;

    printf("Message\n");
    y=getc(stdin);

    fflush(stdin);
    fflush(stdout);

    printf("Message\n");
    y=getc(stdin);

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

我试图fflush …

c codeblocks

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

为什么cout在代码块上没有产生输出?

#include <iostream>
using namespace std;

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

    cout << "Whatever";

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

在此输入图像描述

Cout既不起作用,也不起作用,也不起作用,也不起作用.此外,我检查了项目属性,调试和发布都设置为"控制台应用程序"和"最后暂停".这没有道理.

编辑:另外,我之前尝试过使用endl(没有结果).

c++ iostream cout codeblocks

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

'//'和'///'之间的C++差异

为什么在Code :: Blocks中至少'///'是深蓝色而'//'是蓝色的?我在一些源代码中看到,有时他们使用'///'和其他时间'//'.

c++ codeblocks

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

如何将c ++变量数据放入system()函数

如何将c ++变量数据放入system()函数?

看下面的代码:

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
  cout << "name the app u want to open";

  string app;

  cin >> app;

  system("start app"); // I know this will not work! But how to make it will?
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ windows codeblocks

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

为什么这个C代码在Codeblocks中编译,而在Visual Studio中不编译?

当我尝试使用默认的C/C++设置在Visual Studio 2017上编译以下C代码时:

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


/* function declaration */
/*Line 6*/ int max(int num1, int num2, int num3); 

int main() {

/* local variable definition */
int a = 100;
int b = 200;
int c = 400;
int ret;

/* calling a function to get max value */
ret = max(a, b, c);
printf("Max value is : %d\n", ret);
return 0;
}

/* function returning the max between two numbers */
/*Line 25*/ int max(int num1, int …
Run Code Online (Sandbox Code Playgroud)

c c++ codeblocks visual-studio visual-studio-2017

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

在分配了new []的阵列上使用avx时出现分段错误(核心转储)

当我在Visual Studio 2015中运行此代码时,代码可以正常运行,但是代码在代码块中生成以下错误:分段错误(核心已转储)。我也用同样的错误在ubuntu中运行了代码。

#include <iostream>
#include <immintrin.h>

struct INFO
{
    unsigned int id = 0;
    __m256i temp[8];
};

int main()
{
    std::cout<<"Start AVX..."<<std::endl;
    int _size = 100;
    INFO  *info = new INFO[_size];
    for (int i = 0; i<_size; i++)
    {
        for (int k = 0; k < 8; k++)
        {
            info[i].temp[k] = _mm256_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
                20, 21, 22, 23, 24, 25, 26, 27, …
Run Code Online (Sandbox Code Playgroud)

codeblocks intrinsics avx c++11

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