我正在尝试用C语言编写程序(Windows中的代码::块).我已经添加了下面的头文件,它编译没有错误,但是当它运行代码时,它会抛出一个错误未定义的引用gotoxy.找到完整的代码.我遇到gotoxy语句时会出现错误.
# include<stdio.h>
# include<conio.h>
# include<malloc.h>
# include<stdlib.h>
# include<windows.h>
#include<dos.h>
struct node
{ int data;
struct node *link;
};
void append(struct node **,int);
void in_begin(struct node **,int);
void del(struct node **,int);
void in_middle(struct node **,int,int);
int count(struct node *);
void display(struct node *);
char ans;
int main()
{ struct node *p; /* p can be said as the head or a start ptr */
p=NULL;
/* Printing the menu */
int num,loc;
char choice;
do
{ //clrscr();
printf("PROGRAM …Run Code Online (Sandbox Code Playgroud) "Hello - Debug" uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping...
Run Code Online (Sandbox Code Playgroud)
当我尝试运行一个简单的HelloWorld程序时,我收到了上面的消息,如下所示。
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
关于为什么会发生这种情况以及我如何解决它的任何想法仅供参考:我目前使用 GNU GCC 编译器,我也尝试更改它,但没有用。
好,
所以我被困在这里.我有一个程序的代码,系统地执行基于算法的人站在一个圆圈,但我有一个问题,它在发布模式崩溃.如果我使用调试器(codeblocks)运行它,我的代码运行正常,但如果我不运行它会崩溃.我在网上四处看看,我发现的唯一的东西是未初始化的变量,但我试着在声明时立即为我的变量设置值,但它没有解决问题.
如果有人能看到我的问题,我将非常感谢帮助.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
// if the program does not work, please run in debugger mode. It will work.
void remove_person(int** array, int arraySize, int position)
{
int i;
for (i = 0; i < arraySize; ++i)
printf("%d ", (*array)[i]);
printf("\n");
int* temp = malloc((arraySize - 1) * sizeof(int)); // create temporary array smaller by one element
memmove(temp,*array,(position+1)*sizeof(int)); // copy entire array before position
memmove(temp+position,(*array)+(position+1),(arraySize - position)*sizeof(int)); // copy entire array after postion
for (i = 0; i …Run Code Online (Sandbox Code Playgroud) 我在代码块中有一个项目,它使用许多不同的文件 - 通常由其他程序员编写。目前,我有两个不同的子项目,其中包含以相同方式命名的函数。假设:F(int x)。所以 F(int x) 在两个不同位置的两个源文件中定义,它们有两个不同的标题。我还为这些标头创建了两个不同的命名空间:
namespace NS1
{
extern "C"{
#include "header1definingF.h"
}
}
namespace NS2
{
extern "C"{
#include "header2definingF.h"
}
}
Run Code Online (Sandbox Code Playgroud)
但是编译器仍然抱怨它有多个 F(int x) 定义。我如何在 Code::Blocks 中解决这个问题(在 Visual Studio 中它工作得很好)。
编辑:为了更清楚这些头文件包括 C 代码。没想到会这么乱 有数千个源文件使用其他项目,包括数千个函数……那该怎么办。我完全不知道如何使它工作。
我正在使用Code :: Blocks并希望启用gdb python.所以我按照C :: B wiki http://wiki.codeblocks.org/index.php?title=Pretty_Printers进行配置.
我的pp.gdb与wiki中的相同,只不过我将路径替换为printer.py的路径.
python
import sys
sys.path.insert(0, 'C:/Program Files (x86)/mingw-builds/x32-4.8.1-posix-dwarf-rev3/mingw32/share/gcc-4.8.1/python/libstdcxx/v6')
from printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
Run Code Online (Sandbox Code Playgroud)
然后我测试了它:
(gdb) source C:\Program Files (x86)\mingw-builds\x32-4.8.1-posix-dwarf-rev3\mingw32\bin\pp.gdb
Run Code Online (Sandbox Code Playgroud)
并且错误消息显示:
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "C:/Program Files (x86)/mingw-builds/x32-4.8.1-posix-dwarf-rev3/mingw32/
share/gcc-4.8.1/python/libstdcxx/v6/printers.py", line 911, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "c:\program files (x86)\mingw-builds\x32-4.8.1-posix-dwarf-rev3\mingw32\
share\gdb/python/gdb/printing.py", line 146, in register_pretty_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
C:\Program Files (x86)\mingw-builds\x32-4.8.1-posix-dwarf-rev3\mingw32\bin\pp.gd
b:6: Error in sourced command file:
Error while executing …Run Code Online (Sandbox Code Playgroud) 我在 Windows 7 上使用 Code::Blocks 12.11。
我正在编写用于学习的小程序,它们似乎不包含任何无限循环,但无论如何,Build->Abort 在我发现在 Build->Run 之后出于某种原因必须使用它的那些情况下不起作用。
在最近的这种情况下,屏幕底部的“日志和其他”窗口的“构建日志”选项卡中会显示以下内容。
检查是否存在:C:\CodeBlocks\Test_Cpp11\bin\Debug\Test_Cpp11.exe 正在执行:“C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe”“C:\CodeBlocks\Test_Cpp11\bin\Debug\Test_Cpp11.exe” exe”(在 C:\CodeBlocks\Test_Cpp11 中。)
我退出 Code::Blocks,回来,重新打开项目,并立即运行程序,它运行良好。
编辑:我发现了问题。如果显示 cout 语句的“控制台窗口”仍然打开,那么在关闭该窗口之前,您将看到一个灰色的 Build->Run 和 Build->Build 项目。我当时需要执行 Build->Abort 的假设是不正确的。正如下面的答案所指出的,这无论如何都不会中止正在运行的项目进程,只会中止可能正在运行的构建/编译进程。
我正在为一个柜台写一个代码.如果我给'a'作为输入,它应该+1计数器并在屏幕上显示它.但是当我这样做时,它在屏幕上显示1并且程序结束.我希望它一直运行,除非我给出一些其他字符作为输入.我犯的错是什么?
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int Counter = 0;
char t;
while(true)
{
t = cin.get();
if(t == 97)
{
Counter = Counter + 1;
}
else
break;
system("cls");
cout << Counter;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我已经在我的 linux mint 中安装了 Code::Blocks 12.11,但是在运行时在命令行中粘贴输入(我认为它被称为命令行)似乎不起作用。我必须输入整个输入才能获得输出。可以有人告诉我如何解决这个问题吗?
PS :- 我已经绑定了 ctrl+V 以及右键单击和粘贴,但在我的情况下没有真正起作用
如何在 Code::Blocks 的编辑器窗口中显示垂直右边距线(通常为 80 个字符)?
似乎,双精度的块参数调用to_ary了传递的对象,而lambda参数和方法参数则不会发生这种情况。确认如下。
首先,我准备了一个obj在其to_ary上定义方法的对象,该对象返回除数组(即字符串)之外的其他内容。
obj = Object.new
def obj.to_ary; "baz" end
Run Code Online (Sandbox Code Playgroud)
然后,将其传递obj给具有双斜线参数的各种构造:
instance_exec(obj){|**foo|}
# >> TypeError: can't convert Object to Array (Object#to_ary gives String)
Run Code Online (Sandbox Code Playgroud)
->(**foo){}.call(obj)
# >> ArgumentError: wrong number of arguments (given 1, expected 0)
Run Code Online (Sandbox Code Playgroud)
def bar(**foo); end; bar(obj)
# >> ArgumentError: wrong number of arguments (given 1, expected 0)
Run Code Online (Sandbox Code Playgroud)
从上面可以看到,只有代码块尝试obj通过调用(潜在)to_ary方法转换为数组。
为什么代码块的双斜线参数的行为与lambda表达式或方法定义的行为不同?
codeblocks ×10
c++ ×3
c ×2
c++11 ×1
copy-paste ×1
crash ×1
debugging ×1
gdb ×1
gutter ×1
header ×1
ide ×1
lambda ×1
linux ×1
linux-mint ×1
margin ×1
parameters ×1
python ×1
release ×1
ruby ×1
while-loop ×1