Questions tagged [c]

C is a general-purpose programming language used for system programming (OS and embedded), libraries, games and cross-platform. This tag should be used with general questions concerning the C language, as defined in the ISO 9899 standard (the latest version, 9899:2018, unless otherwise specified — also tag version-specific requests with c89, c99, c11, etc). C is distinct from C++ and it should not be combined with the C++ tag without a specific reason.

Filter by
Sorted by
Tagged with
1 vote
2 answers
53 views

typedef struct <struct_name> vs simply typedef struct [duplicate]

typedef struct Node{ int data; struct Node *next; }Node; typedef struct{ int data; Node *next; }Node; What is the difference between these two, i.e between struct Node <name> ...
FirstTree's user avatar
0 votes
1 answer
26 views

Correct usage of Thread counting semaphores in a Producer and Consumer example

I'm new to Threadx and counting semaphores functionality. I have a code as shown below (didn't compile, just as pseudo). I have thread which produces Data and the other Thread is consuming the data. I ...
JohnDoe's user avatar
  • 861
0 votes
0 answers
36 views

Tic Tac Toe Loading save from a file

I have been trying to make a Tic Tac Toe game, which prints out a board from the users input, and I have managed to save the boards current state the grid's size and the round count. But when I try to ...
Moppity's user avatar
0 votes
0 answers
18 views

Cannot link against .so file - undefined

I have a very short sample code that I wanted to run, using an external library, but I cannot get my code to work with that library. What I have is a .h and a .so file (I am coming from Windows, there ...
SinisterMJ's user avatar
  • 3,443
1 vote
0 answers
27 views

How to receive byte from USB using LUFA for AT90USB162?

using LUFA demo from: /Demos/Device/ClassDriver/VirtualSerial/ I cleared all the code of garbage (joystick and LEDs), all that was left was this: #include "VirtualSerial.h" ...
piro-s's user avatar
  • 11
1 vote
2 answers
90 views

Does calling an empty function in C invoke UB?

#include <stdio.h> static int foo(){} int main(){ if (foo()) { printf("OK\n"); } return 0; } I am not very sure abort that, and I didn't find any explain in ISO/IEC 9899:...
wby's user avatar
  • 11
0 votes
1 answer
25 views

ListView editable, with GTK4, C and VFL

The new possibilities of GTK4 regarding TreeView are not easy to implement. So it would be nice to have an introductory example of this. After a few hours and with the help of valuable advice from ...
Holger's user avatar
  • 40
0 votes
1 answer
46 views

Trouble with Timestamp Communication Between Master and Slave Sockets in C

I have two functions in C that involve communication between a master and slave socket. The master sends a timestamp to the slave using the sendSyncMessage function, while the slave receives it using ...
Varun Bhat's user avatar
0 votes
0 answers
37 views

What Value Should Be Initialized In addrinfo When Using getaddrinfo( )

in the third parameter of getaddrinfo, there was a pointer to the addrinfo struct, but what value i should Initialized in the addrinfo object, because in the addrinfo struct there are several value ...
onxy tzy's user avatar
1 vote
3 answers
116 views

Is char s[] = {"ABC"}; legal?

#include <stdio.h> int main(){ char s[] = {"hello"}; printf("%s", s); return 0; } This code can be compiled and executed successfully,but how can one dimension ...
GongNanyue's user avatar
1 vote
0 answers
34 views

Reparenting a console host window has rendering issues

I reparented the console window retrieved by AllocConsole() to a window owned by a different process using the following code: SetParent(console, main_window_handle); SetWindowLongPtr(console, ...
Tintenfisch's user avatar
-2 votes
1 answer
81 views

Am I doing the dynamic memory allocation correctly without doing any memory allocation for unnecessary space?

How much memory gets allocated for the stack dynamically for this code? #include<iostream> using namespace std; #define max_size 100 typedef struct stack { int top; int capacity; ...
Debbie's user avatar
  • 909
-2 votes
3 answers
67 views

If statement using a character or string in C not working

I'm trying to create something that gets an input from a user which is a y or n and using an if statement to check which one it is. char shChoice[1]; printf("Would you like to buy something ...
Sedourikku's user avatar
1 vote
0 answers
32 views

unable to use headers with vscode

I am trying to use headers in vscode but I run through a lot of problems this is print.c #include <stdio.h> void print1to10() { for (int i = 1; i <= 10; i++) printf("%d &...
Huzaifa Omar's user avatar
0 votes
0 answers
27 views

free'ing after allocation seems to crash my code in interplay with intel's mkl_sparse library

I am currently updating a piece of Code that eventually should be used inside a loop for time evolution. I have encountered some problems thatseem to come down to the notorious pointer allocation and ...
Peter Sanctus's user avatar
1 vote
2 answers
58 views

C passing array to function to modify array

I am learning C and I have a bit of a basic problem. I am using C:How To Program by Deitel and Deitel 8th Edition. I modified the code in Fig 6.13 a little bit to create an array and then pass it to a ...
Wolfgang Hoehenwarter's user avatar
-3 votes
0 answers
66 views

Why doesn't my code call the Void function if I use the \n expression in the main function? [closed]

int isPalindrome(char name[]) { int i,count; int uzunluk; for(int i=0; name[i] != '\0'; ++i) { uzunluk++; } for(i=0; i<uzunluk/2; i++) { if(name[i] == ...
Yiğit Özer's user avatar
-2 votes
1 answer
47 views

calendar scheduler in C

hey so i'm very new to C and i'm having problems in my code #include <stdio.h> #include <windows.h> #include <string.h> #include <time.h> #include <ctype.h> #include <...
presudeous's user avatar
0 votes
0 answers
29 views

About Mechanism of Memory Release in Boehm GC

I am studying the workings of Boehm GC (Garbage Collector). One aspect I am trying to understand is the specific operations that occur on the computer when Boehm GC releases memory. How does the C ...
Taiga Imai's user avatar
0 votes
0 answers
30 views

How to build the syntax tree of a C language project folder [closed]

I want to generate the syntax tree for a C project in a project folder, where the C files may contain comments, macro definitions, etc. What language and syntax tree library should I use I have ...
Higher's user avatar
  • 1
0 votes
3 answers
85 views

How does C's grammar allow this unnamed nested struct?

The K&R and Microsoft grammars for C indicate this simple struct: struct { int a ; } ; matches a declaration while parsing like this: declaration  declarationSpecifier ';'   typeSpecifier ';'    ...
joe snyder's user avatar
  • 3,639
-4 votes
0 answers
28 views

why scanf is not working in a code when showing keyboard buffer [closed]

The first argument to scanf() is a format string, describing what scanf() should parse. The important thing is: scanf() never reads anything it cannot parse. In our example, we tell scanf() to parse a ...
Prashant Panwar's user avatar
-4 votes
0 answers
42 views

How to swap a nibble in a byte [closed]

without changing character cases. For example hexadecimal AB to BA hexadecimal cd to dc. I'm getting my answer in lower cases, how to change it to upper cases when the input is in upper case and lower ...
behindmask_'s user avatar
0 votes
0 answers
26 views

how the message broker can hold client side program when program reached to the end function and still run well?

i have still unclear how the message broker can hold the client side let say in here package main import ( "bytes" amqp "github.com/streadway/amqp" "log" ...
ardi-nugraha's user avatar
-2 votes
0 answers
31 views

Problem setting alarm 2 on the DS3231 using the Raspberry Pi Pico

I am attempting to set an alarm on a DS3231 RTC device from Adafruit. I have no trouble getting and setting the date time on the module along with the Status and Control registers. I would like a 1-...
WINN's user avatar
  • 12
0 votes
2 answers
65 views

Writing Bubble Sorting Function [closed]

I'm trying to write a simple bubble sort function to sort some random data. Whenever executed though it simply prints the unsorted list as it was written initially. Where did i go wrong??? Code: #...
Charlie Webster's user avatar
0 votes
0 answers
55 views

How to make rounded GL_POINTS square?

I am trying to draw GL_POINTS, but when I draw them they are rounded instead of square-shaped, which is what I want. I am using immediate mode and just doing a simple glBegin(GL_POINTS); glVertex2i(20,...
robert Vincent's user avatar
1 vote
0 answers
27 views

Why does calling my MIPS matrix multiplication function cause my PSP to crash?

I've been trying to learn how to use the PlayStation Portable's (PSP) vector floating-point unit (vfpu), and I decided the first thing to write for it would be a simple matrix multiplication function ...
Jayanky's user avatar
  • 11
-1 votes
2 answers
93 views

GCC warning for unintended pointer arithmetic on string literals

With the constant chopping and changing back and forth between different languages, every now and then I find myself trying to write fragments of Python or JS syntax in C/C++. One that's caught me out ...
Richard Lang's user avatar
0 votes
1 answer
50 views

My function only works if there is a printf before it

I'm doing a class homework, I wrote a function to erase a element from an array, and it started failing when trying to erase the next to last element. It sometime would erase the last 2 elements. The ...
Serye's user avatar
  • 1
0 votes
0 answers
12 views

Simulate a 2MB directly mapped write back cache

I am trying to write a c program that is able to successfully read and write to and from memory into the cache. There are a few tests I have to pass, that is my program needs to write to each entry ...
oreocookie's user avatar
0 votes
1 answer
60 views

Why does this code print different values compiled by clang and gcc?

asm.s: .intel_syntax noprefix .global Foo Foo: mov ax, 146 ret main.c: #include <stdio.h> extern int Foo(void); int main(int argc, char** args){ printf("Asm returned %d\n&...
gaver879's user avatar
0 votes
0 answers
17 views

Compiler creates linkern, edgegen, fmatch but does not create concorde

I am trying to compile Concorde with little to no prior knowledge about C. I have made some progress but the README file states the following: configure determines many features about your operating ...
Berk Karasu's user avatar
0 votes
1 answer
25 views

Multi-textured floor rendering in 2D raycaster

In this wonderful lodev's raycasting tutorial (https://lodev.org/cgtutor/raycasting2.html), we have a part about floor and ceiling. I bet my problem is simple, but I can't help myself. Using the ...
OrionExp's user avatar
0 votes
0 answers
45 views

How to organize the architecture of a C application? [closed]

I'm not entirely sure of the correct organization of the source codes and their interaction. My application is quite simple - it is a table editor with accompanying addition/removal of columns and ...
flcl8193's user avatar
0 votes
0 answers
30 views

Issues with moving map in curses in c

I am working on 2d terminal game like space invaders but with moving map. I have a issue where the map moves to the top and after reaching the top edge it changes characters of another wall coming ...
Matak Sendy's user avatar
0 votes
0 answers
54 views

How to properly prioritize priority queue heap in ascending order in C?

My program for school works almost as expected, my priority queue is able to have values inserted and removed properly, and things are stored as expected. However my output looks strange as the values ...
Clark LaBella's user avatar
0 votes
0 answers
34 views

Uni IT mini-project: "Maze & Graph random generation"

Task details: Generate a random 2x2 - 10x10 (size = number of maze's cells, defined by user) maze using any known algorithm (the cells '.' are surrounded by walls '#') The maze consists of cells (2x2 ...
matikosowy's user avatar
-2 votes
2 answers
116 views

Stack overflow in a recursive function

I have two functions, I could get rid of the one that makes the mistake, but I don't really want to rewrite almost all my code away, so I need to fix that in any other way. int Reveal(char*** arr, int*...
Felipe's user avatar
  • 9
-1 votes
1 answer
41 views

compilation errors when using make when installing gcc

I have already turned the .tar.bz2 (I was installing gcc-4.2.2) file into a folder, entered this folder, and used its ./configure, wrote make on the command line. It was after make that I got a lot of ...
OnlyShadow's user avatar
0 votes
2 answers
52 views

Sequential Search returning random numbers at index variables

void introducirarray(int numeros[20], int numbusca) { printf("Por favor introduce el número a buscar"); scanf("%i", &numbusca); char end = '0'; for (int i = 0; ...
communistfunnyman's user avatar
0 votes
0 answers
30 views

Why this Concatenate function in ASM x64 doesn't work as desired?

I've created the following Concat function in GAS x64 assembly, i expect it to get two pointers to two strings in rdi and in rsi, and output pointer to concatenated string of this two in rax. 1 ....
Bartek_0x00's user avatar
0 votes
1 answer
25 views

How is to create button with icon in WINAPI

I have a button. HWND button = CreateWindow("button", "test_text", WS_VISIBLE | WS_CHILD, 0, 0, 500, 500, window, NULL, NULL, NULL); "window" is my HWND variable of my ...
Rarest Loki's user avatar
2 votes
1 answer
33 views

Override read function, but i have problems when the file descripot is 3 or 4

I want to override the read function of netstat -tunap, when am running the strace for netstat -tunap the part that i am interested on overriding is this part right here, openat(AT_FDCWD, "/proc/...
Andreas Frangos's user avatar
0 votes
0 answers
26 views

HAL define bug with STM32WLE5CCU microcontroller

Im trying to use interrupts from UART DMA and SubGhz with STM32WLE5CCU in STM32Cube IDE. I noticed that I don’t get interrupts from both when I don’t define delay time between the configurations. The ...
hezki's user avatar
  • 1
-1 votes
0 answers
57 views

C class hiding methods

I have used typed pointers to methods (i.e. this refers to C++ methods), then redirected its instance to a correct class definition by using macro #define c(x) (*(x->this) = x), which is in the ...
Franjo's user avatar
  • 9
0 votes
1 answer
54 views

stm32 C Global Variables do not have their initialized values [closed]

Was working on an EVAL board stm32G474RE which has FLASH of 512K and RAM of 128K. Everything was working fine on the EVAL board. Now we received the actual hardware which is a stm32g474CBU. Very ...
Nabs's user avatar
  • 1
-1 votes
3 answers
58 views

Something wrong with multi dimensionals matrixes and the functions

firstly Ι wrote a programma that invert a matrix...but now i wanted to seperate the first programm in function and now it has a bug that i cant spot #include <stdio.h> #include <time.h> #...
JOHN BOURAS's user avatar
0 votes
0 answers
31 views

ldap_search() sort on server side [closed]

I'm using the ldap_search function with the limit function to retrieve only the X first result : https://github.com/Alinto/sope/blob/a507a6fbb58a26dc7ac3b875be82294b31f7eada/sope-ldap/NGLdap/...
SlumTheSlug's user avatar
0 votes
1 answer
28 views

How to bpf_probe_read_str all ctx->argv elements in kernel space and forward it to the userspace?

I am new to eBPF and currently trying to send all the executed commands with arguments in the userspace using a perf map. I manage to send most of my data, but not the one accessed with ...
Sathi's user avatar
  • 1

1
2 3 4 5
8030