Tag: 代码块

错误:在’&’标记|之前预期’;’,’,’或’)’ 在线发现一个简单的C程序

我在网上找到了这个程序来练习C.当我尝试在Code块中编译这个程序时,我在’&’token |“之前在两个地方收到此错误”错误:预期’;’,’,’或’)’ (在代码中提到)。 如果有人能解释我错误的原因,那将非常有帮助。 #include int f1(int x,int y) { x=x+2; y=y+3; return x+y;} int f2(int &x,int y) //error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token| { x=x+2; y=y+3; return x+y; } int f3(int *x,int *y) { *x = *x+2; *y = *y+3; return *x+*y; } int f4(int x,int &y,int *z)//error: expected ‘;’, ‘,’ […]

在GCC中编译C文件时出错(多个文件合二为一)

该程序certificate了一串文本。 这是我的代码(main是justify.c): justify.c #include #include “line.h” #include “word.h” #define MAX_WORD_LEN 20 int main(void) { char word[MAX_WORD_LEN+2]; int word_len; clear_line(); for(;;) { read_word(word, MAX_WORD_LEN+1); word_len = strlen(word); if(word_len ==0) { flush_line(); return 0; } if (word_len >MAX_WORD_LEN) word[MAX_WORD_LEN]=’*’; if(word_len + 1 > space_remainding()) { write_line(); clear_line(); } add_word(word); } } line.c #include #include #include “line.h” #define […]

与arm微控制器串行通信

我试图通过usb从arm cortrx m4微控制器发送数据到pc。 在codeblocks ide中有一个用C ++语言编写的程序。 基本上,程序使用ReadFile函数设置串行通信设置和读取数据。 问题是即使pc proogram和微控制器中的波特率相同,我在输出端也会得到垃圾值。 我怎么解决这个问题? 电脑程序如下所示。 #include #include int main(void) { HANDLE hComm; // Handle to the Serial port char ComPortName[] = “\\\\.\\COM51”; // Name of the Serial port to be opened, BOOL Status; // Status of the various operations DWORD dwEventMask; // Event mask to trigger char TempChar; // […]

‘C’分段故障与2darrays

谁能解释一下为什么这段代码不起作用? #include #include void findAndPrint(char *arr[], int year, int month, int day); int main() { char *dayTab[] = { {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; findAndPrint(dayTab, 3, 3, 3); getchar(); return 0; } void findAndPrint(char *arr[], […]

如何清除Code :: blocks中的输出屏幕?

在turbo c ++中你可以这样做 #include void main() { clrscr(); } 但在代码块我不能使用这个.. 🙁

简单的C程序逐行读取文件

我想要做的是读取文件的第一行,但是在第一行之后只读取以下行,直到命中空格。 我的最终目标是通过向所述行添加/减去时间来询问用户他们想要编辑哪行。 示例文件 My test file 00:19.1 123456 00:35.4 testing whitespace end 期望的输出 1: My test file 2: 00:19.1 3: 00:35.4 码: #include #include int main() { FILE *fptr1, *fptr2; char filechar[40]; char c[50]; int line_number = 1; int replace_line, temp = 1; printf(“Please enter a file name: “); scanf(“%s”, &filechar); if ((fptr1 = fopen(filechar, […]

如何在Code :: Blocks中启用C自动完成?

如何在Code :: Blocks中启用C Std lib函数自动完成?

GCC-无效使用Register

我正在为VS2012编译一个项目,为Windows编译GCC(CodeBlocks)。 在VS2012上一切都很完美。 在GCC下我得到以下编译错误: C:\Users\Piotrek\AppData\Local\Temp\ccfdl0Ye.s|164|Error: invalid use of register| C:\Users\Piotrek\AppData\Local\Temp\ccfdl0Ye.s|166|Error: invalid use of register| C:\Users\Piotrek\AppData\Local\Temp\ccfdl0Ye.s|221|Error: invalid use of register| ||=== Build finished: 3 errors, 14 warnings (0 minutes, 0 seconds) ===| 我正在使用编译器选项-fpermissive – 它应该与错误无关。 我只是无法理解为什么它指向Local Temp文件夹下的临时文件,并说我使用了错误的寄存器? 有没有人知道发生了什么?

代码块调试问题

我试图在代码块中运行一个简单的链表程序,但我无法运行该程序,我收到以下错误: Active debugger config: GDB/CDB debugger: Default Building to ensure sources are up-to-date Selecting target: Debug ERROR: You need to specify a debugger program in the debuggers’s settings. (For MinGW compilers, it’s ‘gdb.exe’ (without the quotes)) (For MSVC compilers, it’s ‘cdb.exe’ (without the quotes)) 我尝试了Stack Overflow上给出的一些post,但是这个设置已经存在于代码块中了。

在CodeBlocks中查看语言(C / C ++)参考/文档

关于StackOverflow的第一个问题…… 有没有人知道通过CodeBlocks查看语言的参考/文档手册的方法? 专门针对C / C ++。 例: 假设我想查找strncpy()的引用。 在一个非常古老的Borland系统(我们在学校使用)中,我会写下这个单词并在其上单击鼠标,从而将其作为参考。 如果可以以某种方式浏览手册,那也很好。 我是否完全忽视了这一点(也在搜索谷歌),还是缺少了? 如果它丢失了,那么在没有在线的情况下搜索C和/或参考手册的最快方法是什么? 问候!