Skip to main content
Filter by
Sorted by
Tagged with
23 votes
1 answer
3k views

I have found a piece of code that defines register access permissions for a chip. Using arm-none-eabi-gcc it compiles correctly. Here is the code: static const uint8_t defaultRegisterAccess[...
2A-66-42's user avatar
  • 890
Advice
1 vote
21 replies
261 views

I just wanted to ask if it's possible to read to a specific file format, say if I wanted to read from a file that has a format of something "info.uc" or "main.uc", how would I go ...
ShizamDaGeek's user avatar
Advice
1 vote
22 replies
304 views

From the man pages, I found that size_t has the range of 0 to SIZE_MAX, and ssize_t has the range of -1 to SSIZE_MAX. So, after printing those values on a 64bit system, I have the following results: ...
sat0sh1c's user avatar
11 votes
7 answers
1k views

I want to use circular queue with different types and lengths in a project which mainly consists of C code. I'm thinking about implementing the circular queue as a C++ template struct. How to expose ...
Jackoo's user avatar
  • 503
6 votes
3 answers
384 views

I've got a list P of 2-dimensional points, 100 ≤ |P| ≤ 100000, and a list C of circle centers, 100 ≤ |C| ≤ 100000. All coordinates (x,y) ∈ P or (x,y) ∈ C are integral, 0 ≤ x,y ≤ 4095. P and C may ...
hidefromkgb's user avatar
  • 6,002
7 votes
2 answers
366 views

I’m using an official SDK that provides an api.h header file. When I try to compile, I get the following error, with wriggles on cmd: type containing an unknown-size array is not allowed Here are the ...
Luigi's user avatar
  • 411
3 votes
3 answers
197 views

I am building a c extension for a python module and it needs to work the same on a windows machine and on a raspberry pi. #include <stdio.h> #include <string.h> #include <ctype.h> #...
KarlTheKrazyKat's user avatar
10 votes
1 answer
493 views

The order of bits in C11 bitfields is implementation-defined, and so is any padding in between them. This makes it difficult to access the bitfields by index at runtime, even though most ...
jpa's user avatar
  • 12.5k
Best practices
1 vote
7 replies
161 views

So I'm making a linked list for one of my school assignments in C. I found this website that has some helpful code snippets, and I noticed that they use malloc() to allocate more memory every time ...
Klumpy7's user avatar
  • 123
Best practices
1 vote
7 replies
124 views

I have automated tests for fairly complex software, which send SIGQUIT signals at program startup. If the signal arrives before the handler is installed, a coredump is generated, causing the test to ...
se_pavel's user avatar
  • 2,208
3 votes
3 answers
155 views

I am currently writing a program in C to convert numbers between bases as an exercise. It asks the user for an input and for the base, that the number given is. It then gives the input into the ...
Brentspine's user avatar
  • 1,040
6 votes
2 answers
275 views

All the existing threads I can find for this type of problem only refer to reversing endianness on byte-multiple bit sizes (i.e, 8, 16, 32, etc), but not non-byte-multiple (i.e, 5, 13, 20, etc), so ...
Nasir's user avatar
  • 91
2 votes
2 answers
151 views

I am trying to use an MSP-EXP3430G2ET with a Buzzer and a potentiometer on CCS. The goal of the program is to have 2 modes, a high frequency mode and a low frequency mode. If you press the button, it ...
Sofia Happy Banya Ceregido's user avatar
3 votes
2 answers
132 views

typedef union { unsigned long anyvariable; float output; } map; return (*(map*)&fraction32).output; I copied this method of accessing the members of a union which ...
Cosmo Little's user avatar
3 votes
2 answers
145 views

Please consider the following minimal example: #include <stdio.h> // Compile with: // gcc -g -o myprogram main.c //#define SPECIAL typedef struct { int id; char name[50]; float value; } ...
sdbbs's user avatar
  • 5,948
-3 votes
1 answer
181 views

I am following the Bro Code course of C and there is something I am not fully understanding. This might be a basic question, but I cannot figure out what is going on behind the function fgets. When ...
VICTOR HUGO CORREA - MARQUEZ's user avatar
1 vote
2 answers
210 views

I am mostly programming in C, yet some of my code is in C++. The code compiles fine using gcc/g++ under Linux, yet VisualStudio Code's IntelliSense is reporting include errors with the following setup:...
kalle's user avatar
  • 135
0 votes
1 answer
158 views

In my homework assignments I've got a task to get an input using scanf() of an integer number and check if its a positive negative or zero. I've coded this: #include <stdio.h> int main() { ...
CallMeEdwin's user avatar
2 votes
2 answers
112 views

I recently started learning C and as a learning project I tried creating a tic tac toe bot using the Minimax algorithm. Here is the code that I have written so far: #include <stdbool.h> #include ...
floatingCatsAndDogs's user avatar
3 votes
1 answer
179 views

I was reading an article on the Memory Layout of C Programs; https://www.geeksforgeeks.org/c/memory-layout-of-c-program/. It mentioned, under "4. Stack Segment": When the stack and heap ...
Supreeto's user avatar
  • 339
1 vote
1 answer
127 views

My code should print the numbers given as command line arguments. Instead it prints random-looking values. What is going on and how can I fix it? #include <stdio.h> #include <pthread.h> #...
user31884282's user avatar
1 vote
2 answers
148 views

The following code is trying to set the test array in the first for loop, but it can't be used in the second for loop. int main() { int *test[3]; /** Try to set the array value one by ...
stackbiz's user avatar
  • 1,916
3 votes
2 answers
97 views

Im new to C Programming and the Windows API im getting "Run-Time Check Failure #2 - Stack around the variable 'pMyStringAdress' was corrupted." after compilation in Visual Studio Thats my ...
reiner's user avatar
  • 33
8 votes
1 answer
174 views

If I start two threads bound to CPU 0, where one is SCHED_IDLE, then why is it ever scheduled when the other thread is CPU bound at either normal priority, or at SCHED_FIFO? For SCHED_FIFO I get it, ...
Thomas's user avatar
  • 4,426
Advice
2 votes
7 replies
117 views

I know that it's possible to take the address of an inline function, just like with ordinary functions. But if each translation unit has its own inline definition, and I take the address of the ...
Morel's user avatar
  • 1