Tag: c

C trie试图添加撇号

我正在尝试在C中编写一个trie来读取文件并将文件中的所有单词添加到trie中,并且它运行良好,但我不能让它接受撇号: typedef struct node { bool wordBool; struct node* next[27]; // 26 letters and one space for the apostrophe } node; node* base; int numWords = 0; bool load(const char* dictionary) { FILE* dictionaryf = fopen(dictionary, “r”); // the file to read base = malloc(sizeof(node)); node variable; node *currNode = &variable; int n = 0; […]

项目欧拉#8

我试着自己解决这个问题,但一段时间后卡住了,所以看了解决方案。 问题#8 。 这就是我得到的。 #include int main(void) { char str[] = “73167176531330624919225119674426574742355349194934” “96983520312774506326239578318016984801869478851843” “85861560789112949495459501737958331952853208805511” “12540698747158523863050715693290963295227443043557” “66896648950445244523161731856403098711121722383113” “62229893423380308135336276614282806444486645238749” “30358907296290491560440772390713810515859307960866” “70172427121883998797908792274921901699720888093776” “65727333001053367881220235421809751254540594752243” “52584907711670556013604839586446706324415722155397” “53697817977846174064955149290862569321978468622482” “83972241375657056057490261407972968652414535100474” “82166370484403199890008895243450658541227588666881” “16427171479924442928230863465674813919123162824586” “17866458359124566529476545682848912883142607690042” “24219022671055626321111109370544217506941658960408” “07198403850962455444362981230987879927244284909188” “84580156166097919133875499200524063689912560717606” “05886116467109405077541002256983155200055935729725” “71636269561882670428252483600823257530420752963450”; size_t len = sizeof str – 1; size_t i; unsigned max = 0; for (i = 0; i < len-4; i++) { unsigned p […]

使用libssh链接期间未定义的符号

我使用libssh来完成两个系统之间的连接,ssh服务器是redhat,客户端是CentOS。 我的代码编译和链接就好了,除了在运行时我一直看到这个, [1] libssh 0.5.5 (c) 2003-2010 Aris Adamantiadis (aris@0xbadc0de.be) Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_noop [2] Nonblocking connection socket: 4 [2] Socket connecting, now waiting for the callbacks to work [1] Socket connection callback: 1 (0) [1] SSH server banner: SSH-2.0-OpenSSH_5.3 [1] Analyzing […]

C指针:struc * A,struct * A和struct * A之间有什么区别?

我正在做一些研究以更好地理解C中的指针,但我很难理解这些:’struct * A’是结构上的指针吗? 那么什么是’struct * A’? 而且我看到有人写’int const * a’,这是什么意思?

g_signal_connect“pad-added”不起作用

我正在尝试学习如何在gstreamer中使用动态垫。 所以我尝试添加pad-added信号,这样我就可以在创建元素后收到消息。 但是,我没有收到任何消息。 这是代码: #include static void cb_new_pad (GstElement *element, GstPad *pad, gpointer data) { gchar *name; name = gst_pad_get_name (pad); g_print (“A new pad %s was created\n”, name); g_free (name); /* here, you would setup a new pad link for the newly created pad */ } int main (int argc, char *argv[]) { GstElement […]

检测Win + Tab任务视图

在Windows 10上,您可以按Win + Tab以获取所有窗口的“任务视图”视图。 我试图在任何给定时间检查这是否有效。 我尝试使用WH_KEYBOARD_LL的低级键盘挂钩,但这只允许我检测按键,而不是切换器处于活动状态。 我查看了Windows DWM API,但也没有找到任何其他内容。 我也尝试过使用EnumWindows()和EnumChildWindows(GetDesktopWindow(), …)并且在显示和隐藏任务视图之间的输出中没有发现任何差异。 有没有准确的方法来检测是否显示?

c – 错误:“不允许不完整的类型”,IAR编译器

请指教,出了什么问题? 在.h struct { uint8_t time; uint8_t type; uint8_t phase; uint8_t status; } Raw_data_struct; typedef struct Raw_data_struct Getst_struct; void Getst_resp(Getst_struct Data); 在.c void Getst_resp(Getst_struct Data) //Here Error: incomplete type is not allowed { };

外部范围时未定义变量

编写一个程序,让用户抛出五个骰子并以“图形方式”显示结果屏幕。 该程序应该首先通过填充一个介于1之间的5个数字的数组来模拟五个掷骰子然后,函数应该通过在屏幕上显示字符和计算函数来“绘制”结果总和。 我得到第一个函数的错误消息,它说我没有定义矩阵,我在“if”中定义了。 #include int sumOfDie(int inputArray[], int arraySize); int drawDie(int inputArray[], int arraySize) { int i, row, column=0; for (i=0; i<arraySize; i++) //determine the graphic number from the random number { if (inputArray[i]==1) { char matrix [3][4] = {{" "},{" * "},{" "}}; } if (inputArray[i]==2) { char matrix [3][4] = {{"* "},{" "},{" […]

以下给出的代码是错误的吗?

#include int main() { int a; printf(scanf(“%d”,&a)); return 0; } 我收到此消息“Segmentation fault(core dumped)”

我怎样才能在C中解决这个问题?

我有一个模拟BMI(身体质量指数)计算器的程序,该计算器接收来自10个用户的输入,询问每个用户的重量和高度,然后程序计算BMI并在格式化的输出中打印计算结果。 像这样的东西: USER BMI STATUS 1 : 10 所以我想到了这一点,我会首先接受用户的输入,然后尝试以上面的格式化方式显示输入的计算。 以下是我试图提出的问题,一直向用户询问他们的体重和身高,直到第10位用户。 #include #include int main(void) { float weight_value = 0.0f; float user_height = 0.0f; float BMI = 0.0f; char BMI_Status[30]; int i; for ( i = 1; i <= 10; i++) { printf("Please enter your weight: "); scanf("%f", &weight_value); //Reads in the user's weight printf("Now enter […]