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.
405,588
questions
0
votes
0
answers
12
views
How can i make a C program exit when key Q is pressed?
i am making a counting program, and i want to add a feature that quits the program, but i don't really know how to do it. i have seen examples on how to do it, but all of them are for windows. please ...
0
votes
0
answers
8
views
Why does printing cause the heap break to increase by this much?
I wrote the following program,
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include "rand.h"
int main (int argc, char* argv[]) {
...
1
vote
0
answers
7
views
Does the EVP_KEY created by OSSL_DECODER_CTX_new_for_pkey need to be manually freed?
Does this code (ignoring lack of error handling) leak with OpenSSL 3.0?
EVP_PKEY *pkey = NULL;
BIO *public_key_file = BIO_new_file("public.pem", "r");
OSSL_DECODER_CTX *dctx = ...
0
votes
0
answers
7
views
Clang error: libdnk.a, libunwind.a and libc++.a linkage issues in windows build
I am trying to build an ELF file using the ARM-M4 toolchain version 8.1.0. My C code files compile successfully, but I encounter the following error while linking the object files
[100%] Linking C ...
1
vote
3
answers
49
views
Read is blocked by getc
For the following code:
#include <unistd.h>
#include <stdio.h>
int main()
{
char buf[6];
printf("%c\n", (char)getc(stdin));
int ret = read(STDIN_FILENO, buf, 5);
...
1
vote
0
answers
10
views
LNK2019 unresolved external symbol in function defined in static library
I am trying to compile a driver through the use of cl.exe on Windows 10. It is written in pure C. I am using the Enterprise Windows Driver Kit to provide source files and compiling for X86. I ...
0
votes
1
answer
39
views
In C language, do multiple implicit conversions that occur in an expression have a certain order?
(My question might be quite long. I would be very grateful if you could read it through.)
I am learning C language by reading the C11 standard. I find that there are quite a lot of implicit ...
0
votes
0
answers
25
views
How can i use functions from libc in NASM 64 bit
im making my own programming language and i wanted to call some functions from libc (es strcat and printf) but im unsure on how to call them correctly(i dont which cpu registry to use and if i have to ...
0
votes
0
answers
11
views
Receiving and Sending J1939 CAN message on Linux in C
I am trying to open a SocketCAN J1939 and receive and send J1939 messages. I am very confused with type "sockaddr_can". This structure has j1939.addr, j1939.pgn, j1939.name etc. When I ...
0
votes
1
answer
50
views
Passing `volatile` buffers to library functions which do not take `volatile`
I have a multi-processor system with a "shared" memory region used for communication. In some cases one of the processors needs to process some considerably large data in the shared memory ...
2
votes
0
answers
60
views
malloc fails even with enough memory
I'm implementing a SkipList for academic purposes in C.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// ===============================================
// SkipList
// ===...
0
votes
0
answers
33
views
Unable to access server running in k8s pod from WSL host with docker-desktop installation
I'm running docker-desktop with WSL2.0 ubuntu on windows. I created a k8s deployment in the wsl ubuntu host. The deployment has one pod where I'm running a simple server program(runs forever, accepts ...
0
votes
0
answers
38
views
Adding attributes to entire c-file instead of specific function
Hi I was trying to add the attribute __attribute__((section(".protected"))) to my whole c file. My temporary solution was to just give this attribute to main() and put all the variables ...
1
vote
1
answer
38
views
iconv: Invalid argument error when passing struct element
I have a function which converts utf-16 string to utf-8 by using iconv library (ignore "ISO-8859-1" part, my test files all are utf-8 and utf-16). Here is it's code:
char* to_utf8(const ...
3
votes
1
answer
47
views
In R, how and where does the underlying C functions get their argument inputs?
I'm trying to understand what happens at the C level when I call a function in R. For instance, print("Hello, World!") will call UseMethod("print"). From the "table" in ...