这是我第一次在Stack Overflow上问一个问题,所以请随意告诉我,如果我做错了什么或不够具体.我现在用C语言编写微控制器大约4个.几天前,我参加了一个电子竞赛.许多问题之一是C代码行究竟是什么
int *(*(x[3])())[5];
Run Code Online (Sandbox Code Playgroud)
确实.这就是我记得的路线.一个支架可能在另一个位置,但我认为这就是这条线.
我的猜测是x是一个功能指针数组,我们采用第四个元素并取消引用它.然后在不移交参数的情况下执行该功能.returnvalue似乎是指向一个数组的指针,我们为了获取第一个元素的地址而将其解引用一次.然后我们选择该数组的第6个元素.我不知道int的用途是什么......
非常感谢你回答我的问题并度过了愉快的一天.
当我试图编译这个程序时,我得到两个错误,一个是:
main.c:34:24: error: expected expression before ')' token
Run Code Online (Sandbox Code Playgroud)
另一个是:
main.c:34:24 error: expected ';' before ')' token
for(i = 0,i<r,i++)<
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
标题:
#ifndef HEADER1
#define HEADER1
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define MAX_LEN 1024
#define SP1 1
#define SP2 2
void eingabe_check();
int spieler_check(int *r);
#endif
Run Code Online (Sandbox Code Playgroud)
main.c:
#include "Header.h"
void eingabe_check() {
}
/* Überprüft welcher Spieler an der Reihe ist*/
int spieler_check(int *r) {
if(0 < (*r % 2))
return SP1;
else
return SP2;
}
int main(int …Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种方法或方法来检查数组中的单个字符
char* s[size] = {
"0-2324-2324-7",
"032121353X",
"0-619-66248-X",
"0-758-50938-6",
"0870495275"
};
Run Code Online (Sandbox Code Playgroud)
我想我必须编写遍历数组中每个条目的for循环和遍历数组内该条目中每个字符的for循环
有点像:
for (int i=0;i<size;i++)
for (int j=0; j<"size of s[i]"; j++) // the size of an entry so "032121353X" would be 10
int* c= "the j character in s[i]" // assigns c the individual character in s[i]
if(c<='0'||c>='9') // checks if its a digit
Run Code Online (Sandbox Code Playgroud) 很抱歉提出这个问题,我试图在stackoverflow上找到解决方案,但没有令人满意的结果.我的代码如下,感谢您的耐心等待.
#include <inttypes.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
typedef uint32_t req_id_t;
typedef uint32_t view_id_t;
typedef uint64_t db_key_type;
typedef struct view_stamp_t {
view_id_t view_id;
req_id_t req_id;
}view_stamp;
typedef struct consensus_component_t {
view_stamp* highest_committed_vs;
}consensus_component;
uint64_t vstol(view_stamp* vs) {
uint64_t result = ((uint64_t)vs->req_id)&0xFFFFFFFFl;
uint64_t temp = (uint64_t)vs->view_id&0xFFFFFFFFl;
result += temp<<32;
return result;
}
int main() {
consensus_component* comp = (consensus_component*)malloc(sizeof(consensus_component));
memset(comp, 0, sizeof(consensus_component));
if(NULL != comp) {
comp->highest_committed_vs->view_id = 1;
comp->highest_committed_vs->req_id = 0;
db_key_type start = vstol(comp->highest_committed_vs)+1;
printf("%" PRIu64 …Run Code Online (Sandbox Code Playgroud) 使用微处理器,我的内存不足,我必须以非常有效和安全的方式执行此操作.
所以我有一些来自服务器的数据,我必须找到它的标题.例如:
char *meida="+IPD,0,206:GET /setWifi:home:0545881255 HTTP/1.1 Host: 192.168.4.1" ;
Run Code Online (Sandbox Code Playgroud)
我只需要得到setWifi:home:0545881255.
strstr在句子中查找字符串的出现.我怎样才能用它来找到2个单词之间的句子?
在下面的代码中,为什么我不能取消引用数组名,因为当一个数组作为参数传递给一个函数时,它就成了指向数组第一个元素的指针,那么为什么我们不能取消引用呢?
#include <stdio.h>
int main(void) {
char s[] = "radha";
int a[2] = {0,1};
printf("%s ", *s);
printf("%d", *a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我为上面的代码得到了分段错误,这里的原因是什么,当我使用[0]时,它在内部被转换为*(a + 0),那么简单地做*a或*S的问题是什么呢?澄清.
无法在Windows的带有-Wall -pedantic -ansi标志的Visual Studio Code终端上执行程序。现在的赋值程序只是一个简单的C语言中的“ Hello World”主结构
我试过在其他文件夹上使用这些标志,它们在VS Code上可以正常工作,但在我想要的文件路径上却不能。
gcc -Wall -pednatic -ansi -o q1 -c Question1.c
Run Code Online (Sandbox Code Playgroud)
这是我在文件夹中的Visual Studio Code终端上执行的操作 .../Assignment_1$
-bash: ./q1: cannot execute binary file: Exec format error
Run Code Online (Sandbox Code Playgroud)
当我做的是什么 ./q1
在堆上创建的对象被分配给堆栈对象.它是某种复制浅拷贝吗?
#include <iostream>
using namespace std;
class Student
{
private:
char *name;
};
int main()
{
Student *s = new Student();
Student s1 = *s;
Student s2;
s2 = s1;
delete s;
// it will delete the object s and s1 and s2 are deleted when out of scope?
//after the curly braces?
return 0;
}
Run Code Online (Sandbox Code Playgroud) push(equation, pop(equation) + pop(equation));
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的流行音乐
int pop(struct stack *st)
{
int c;
if (st->top == -1)
{
printf("Stack is empty");
return NULL;
}
c = st->arr[st->top];
st->top--;
return c;
}
Run Code Online (Sandbox Code Playgroud)
这是推动
void push(struct stack *st, int * c)
{
if (st->top == 99)
{
printf("Stack is full");
return ;
}
printf("TOP = %d\n", st->top);
st->top++;
printf("TOP = %d\n", st->top);
st->arr[st->top] = c;
}
Run Code Online (Sandbox Code Playgroud)
它说push的第二个arg是从一个没有强制转换的整数制作一个指针,但我不明白为什么如果有人能解释它我会很感激.
我需要class在一个线程应用程序中使用它,所以在堆栈上实例化它显然是一个问题,有没有办法强制new在实例化类时使用?
我已经将构造函数private和new运算符公之于众
public:
void *operator new(size_t);
private:
SomeClass(void);
SomeClass(SomeType value);
.
.
.
Run Code Online (Sandbox Code Playgroud)
但正如我预期的那样使用
SomeClass *heapInstance = new SomeClass(value);
Run Code Online (Sandbox Code Playgroud)
编译器告诉我构造函数是私有的.
问题:
注意:我已经使用class了这个地方,现在我需要修复我的代码,即我需要编译器来防止编译所以我不需要手动搜索每个事件,我不是很擅长c ++我只是不得不使用它,因为我需要做一个GUI跨平台应用程序,并选择Qt了几个与此无关的原因.
我的目标是以递归方式编写所有函数,以便让我看起来更聪明.为了好玩,我想出了一个字符串比较功能
#include <iostream>
int string_compare ( char * s1, char * s2 )
{
int retval;
switch ( s1 ? 1 : 0 + s2 ? 2 : 0 )
{
case 0 : retval = 1; break;
case 1 :
case 2 : retval = 0; break;
case 3 : retval = *s1 == *s2 ? string_compare(++s1,++s2) : 0; break;
}
return retval;
}
int main ( )
{
char str1 [] = "hey there",
str2 [] = "hey …Run Code Online (Sandbox Code Playgroud) 我打算打印一个构成字符串和浮点数的输出.例如,我使用D =质量/体积计算了盒子的密度.我现在想生成一个输出"你的盒子的密度是****kg /立方米"
这是如何在C中实现的
printf("The density of your box is %d\n", D);
Run Code Online (Sandbox Code Playgroud)
如何在VBA上实现这一目标?