Category "c"

Why does fread always return 0?

I used this code to read file. But fread function always return 0. What is my mistake? FILE *file = fopen(pathToSourceFile, "rb"); if(file!=NULL) { char a

is it possible to do memcpy in bits instead of bytes?

I would like to know is it possible to do memcpy by bits instead of bytes? I am writing a C code for Ethernet frame with VLAN tagging, in which I need to fill

SDL2 How to draw dotted line

Is is just possible to draw a simple dotted line using SDL2 (or with gfx) like int drawDottedLine(SDL_Renderer *renderer,Sint16 x1,Sint16 y1, Sint16 x2, Sint1

Not able to remove a loadable kernel module

I'm writing a loadable kernel module and trying to test it. After inserting it I was trying to remove it using rmmod xxx command, but I get an error saying modu

SDL_TTF : undefined reference to "TTF_INIT"

I'm trying to learn how to use SDL_TTF library. But i'm unable to solve an error of type : undefined reference to "TTF_INIT" here is the simple code that im t

Draw the midpoint lines between points

I am making generated shapes in a fragment shader and part of it involves drawing the border between objects ie the dividing line between them. Currently I have

What is the difference between exit and return?

What is difference between return and exit statement in C programming when called from anywhere in a C program?

Static assert in C

What's the best way to achieve compile time static asserts in C (not C++), with particular emphasis on GCC?

What is the simplest way of implementing bigint in C?

I am trying to calculate 100! (that is, the factorial of 100). I am looking for the simplest way to accomplish this using C. I have read around but have not fou

Finding consecutive bit string of 1 or 0

How to find the length of the longest consecutive bit string(either 1 or 0)? 00000000 11110000 00000000 00000000 -> If it is 0 then length will be 20 111

In C is it faster to use the standard library or write your own function?

For example, in <ctype.h> there are functions like isalpha(). I want to know if writing an isalpha function on my own is faster than calling isalpha? Th

VS Code C Error - Invalid Active Developer Path

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun This is

How to hide helper functions from public API in c

I'm working on a project and I need to create an API. I am using sockets to communicate between the server (my application) and the clients (the other applicat

Minimal implementation of sprintf or printf

I'm working on an embedded DSP where speed is crucial, and memory is very short. At the moment, sprintf uses the most resources of any function in my code. I o

warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)’

I am trying to run a simple C program but I am getting this error: warning: format ‘%s’ expects type ‘char *’, but argument 2 has ty

Minimal implementation of sprintf or printf

I'm working on an embedded DSP where speed is crucial, and memory is very short. At the moment, sprintf uses the most resources of any function in my code. I o

warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)’

I am trying to run a simple C program but I am getting this error: warning: format ‘%s’ expects type ‘char *’, but argument 2 has ty

hex code implementation for spawning a shell

I am trying to implement the codes given in smashing the stack for fun and profit by Aleph to learn the basics of buffer overflow attacks. Machine architecture:

hex code implementation for spawning a shell

I am trying to implement the codes given in smashing the stack for fun and profit by Aleph to learn the basics of buffer overflow attacks. Machine architecture:

hex code implementation for spawning a shell

I am trying to implement the codes given in smashing the stack for fun and profit by Aleph to learn the basics of buffer overflow attacks. Machine architecture: