Designing a Vector Data Structure in C
Reddit » C
by /u/aurreco
15h ago
Hello everyone. I'm in the middle of working with a custom vector data structure in C. I want to achieve some small level of generics without using macros and settled on letting the vector be a contiguous array of uintptr_t's. If the user wants to fill it with types that are less than the size of a uintptr_t, then great, they can just cast their data and send it in. Anything bigger and they will need to send in pointers to their data along with a custom destructor. I decided to do this so that the user of the vector can handle simple use cases like just a stack of numbers and at the same time ..read more
Visit website
How to I determine the encoding of a file?
Reddit » C
by /u/Mythologicalism
15h ago
I would like my application to be able to read the encoding of a given file similar to file -i command. I merely need to pass on that information, no charset specific processing required on my end. How could I implement such a feature? Within my use-case any information provided by the file command is assumed to be correct. submitted by /u/Mythologicalism [visit reddit] [comments ..read more
Visit website
Looking at ancient C from MS-DOS v4
Reddit » C
by /u/kennbr
15h ago
So I guess Microsoft decided to release the source for MS-DOS v4. So of course I was curious, as I like looking at very old C code. Theirs is a little confusing though... https://github.com/microsoft/MS-DOS/blob/main/v4.0/src/INC/CDS.C I've never seen this way of writing a function. It appears they write the function as it would be called, but then specify the types of its arguments. Like... return-type func(arg1, arg2) int arg1; struct struct-type *arg2; {...function code...} I feel like I recall having read somewhere before that it used to have to be done like that until they switched it to ..read more
Visit website
Want criticisms and advice for my project.
Reddit » C
by /u/Exotic-End-4670
15h ago
Generic Linked List submitted by /u/Exotic-End-4670 [visit reddit] [comments ..read more
Visit website
Best book to learn low latency & high performance C
Reddit » C
by /u/vctorized
15h ago
Ive done some C during my yet short life, i think this lang is very interesting and i find it really fun because the only times ive had to deal with it was during some fun side experiments/projects i did on my own. I want to improve during my free time and become what could be qualified as a "good c programmer" in the future, so i wanted what more experimented C guys would recommend as a good path, im open to anything, projects idea/book recommendations etc. (ps: what high performance c is to me rn is the firedancer solana client which ive read a lot of blogs about and i find the architecture ..read more
Visit website
Float passed as parameter turning into a random number
Reddit » C
by /u/LuckyJinx98
15h ago
So I have defined the following function: void render_text(char *text, float scale) { printf("Scale: %0.6f\n",scale); //... //Some random code } Somewhere else, I call the function like this: render_text("Hola que tal\0",0.7f); And this is the output: Scale: 36893488147419103232.000000 I have tried random numbers, and they transform into either 0.000000, -2.000000, -36893488147419103232.000000 or 36893488147419103232.000000. All I know is: This function is defined one time in a single file. The definition in it's header is correct. There is a single call in the entire code of this functio ..read more
Visit website
`Reading from K&R, chapter 7`. About prog
Reddit » C
by /u/gamerguy45465
15h ago
Hi, I am currently reading through The C Programming Language by K&R. Currently, I'm not quite understanding the following phrase from the book: "In many environments, a file may be substituted for the keyboard by using the < convention for input redirection; if a program prog uses getchar, then the command line prog <infile causes prog to read characters from infile instead." So, can someone please give me some more information on what < means? It says it's for input redirection, but I'm having trouble drawing a mental picture of how that works. Also, is it part of C or the comm ..read more
Visit website
Confused about type-compatibility in type-qualifiers
Reddit » C
by /u/GeroSchorsch
15h ago
I'm implementing type-qualifiers in my C compiler and there seem to be different rules when it comes to assignment which are somehow conflicting or are implemented differently. In the c99 for scalar initialization it says: the same type constraints and conversions as for simple assignment apply, taking the type of the scalar to be the unqualified version of its declared type which sounds like type-qualifiers can be ignored when doing initialization, which isn't the case though with gcc/clang. Another thing that the standard says when defining rules for valid assignments is that two types ar ..read more
Visit website
A question about C and utf-8 encoding
Reddit » C
by /u/IAmTheBlackWizards-
15h ago
So im still quite a beginner in this lanuage. I have made small C projects and generally understand the basics. But something i stumbled upon recently that i really never thought about before is character encoding. Its something i never was introduced to and something that (at least how i percieve it) feels like a pain to deal with. I even got a little dissapointed that id never heard about it before but then again its just something ill have to learn about. So my few questions i got here is: How much will i have to deal with encoding / decoding? Are there any types of programs that totally n ..read more
Visit website
How can I store 2 variables into a single byte?
Reddit » C
by /u/TipsyBonsai
15h ago
So I am doing a project and I have a DHT sensor that is getting the values for temperature and humidity. I want these values to be sent in a single byte of a communications message, I already have the commutations message and the variable is txDHT which is automatically sent to rxDHT at the end of each communications loop, however I need txDHT/rxDHT to be no more than a byte. Im aware you can shift bits in a byte and then put the other value next to it but I don’t know how to do this without it being bigger than a byte. Is there a way I can do this or will I have to do separate variables for ..read more
Visit website

Follow Reddit » C on FeedSpot

Continue with Google
Continue with Apple
OR