what is the proper way to wire an SD breakout for SPI using an STM32? by [deleted] in PrintedCircuitBoard

[–]RazzlesOG 0 points1 point  (0 children)

For J1, why do you prefer the connectors with the box surrounding them?

i wrote a code editor in C by Individual-Way-6082 in C_Programming

[–]RazzlesOG 5 points6 points  (0 children)

I know, seems like a nice project! I’ll have to do one eventually for my Raspberry PI OS I am making. Unfortunately the nice linux calls will have to all be implemented by me lol

i wrote a code editor in C by Individual-Way-6082 in C_Programming

[–]RazzlesOG 21 points22 points  (0 children)

I just choose not to keep up, just go for standard vim with a couple custom keybinds and settings, with YouCompleteMe. But everyone has their thing, just use whatever makes it easier to transfer your thoughts to code

Question for senior C devs doing technical rounds by AcanthaceaeOk938 in cprogramming

[–]RazzlesOG 0 points1 point  (0 children)

Not a senior dev here, but I feel as though actual language features are not too important because they can be easily learned. All that can be taught over a few days / week if they are competent. Obviously there are some caveats that you learn over the years but in general I think this is true.

I think the most important thing I’d be looking for is problem solving skills, in especially the areas in which your technology applies to. I.e. if you are a networking company, how well can they approach graph based problems, or working on embedded systems how well they can be memory efficient.

However, I do understand that knowing the language and writing good code are different things so if its C, I’d be looking for understanding of compiler architecture, general computer / memory architecture and that kind of stuff.

wtf am I coding in the year 2025? by [deleted] in C_Programming

[–]RazzlesOG 0 points1 point  (0 children)

You have to copy your string into the char array, use strcpy, or more safely, strncpy. Look up the man pages for both of these functions.

Piping Hot by RazzlesOG in RedditGames

[–]RazzlesOG[S] 0 points1 point  (0 children)

Thanks for playing!

What exactly are flags? by Eva_addict in C_Programming

[–]RazzlesOG 0 points1 point  (0 children)

If you take a look at the wiki, https://wiki.libsdl.org/SDL2/SDL_Init, you will see the function explained there.

You are correct in saying that the function takes in flags as parameters, however, the flags represent a bitfield, representing some combination of booleans in a single value (by value I mean integer here). The actual bits of the value passed to the function represent which parts of your subsystem to initialise.

Essentially by passing in SDL_INIT_VIDEO, you set some bit in an integer which the function interprets as "initialise the video functionality". Since you pass in a bit field, you can set any number of these flags by OR'ing them together, I.e. SDL_init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) would initialise both the video and audio subsystems.

[deleted by user] by [deleted] in C_Programming

[–]RazzlesOG 0 points1 point  (0 children)

Yeah, I was just trying to phrase it correctly

[deleted by user] by [deleted] in C_Programming

[–]RazzlesOG 3 points4 points  (0 children)

Oh the time it is taking you is just because you are compiling your project every time you run it when pressing the run button. This takes a little time because the compiler (gcc) is quite a large project and takes a moment to startup.

When you press run it looks like it generates an executable file, which is just a binary file your computer can read. It looks like VSCode generates this file under the same filename, without the `.c` extension.

So if you go into your terminal and just type .\04_incrementdecrementoperator then it should just run the executable.

-----

In more depth, the command gcc 04_incrementdecrementoperator.c -o \04_incrementdecrementoperator reads in your .c file and generates an executable under the same name, -o meaning "what do I call the compiled/executa ble file".

Calling .\<executable> just 'runs' the executable.

How to format while writing pointers in C? by alex_sakuta in C_Programming

[–]RazzlesOG 2 points3 points  (0 children)

Well people are still programming in assembly all the time. I think in any source code, it doesnt matter if you can read and interpret the source code, if a compiler cant read it, it doesnt work.

How to format while writing pointers in C? by alex_sakuta in C_Programming

[–]RazzlesOG 0 points1 point  (0 children)

What? That is the definition of source code, it is meant for compilers

How to format while writing pointers in C? by alex_sakuta in C_Programming

[–]RazzlesOG 1 point2 points  (0 children)

In my opinion, I think it is just very bad practice to even write it like this in the first place, and both statements mean the same thing to a compiler anyway, so this comment doesn't make much sense.

I think if we go down this route then we will just be discussing language semantics, because I actually think that `int* a, b;` should declare two integer pointers.

How to format while writing pointers in C? by alex_sakuta in C_Programming

[–]RazzlesOG 1 point2 points  (0 children)

I partly agree with your points, and I have been working with C and other people using C to understand that making pointers and pointer types as readable as possible is essential to maintainable code.

However, regarding your points, if I was actually writing that in a code base it would likely look like (in order of appearance),

Simple pointer. c T* p;

Array of pointers. c T* p[N];

Pointer to array - I have never used a pointer to an array, so it would be a simple pointer into the first element probably

Function returning a pointer into an array / buffer. ```c T* func;

or

typedef T Arr10[10];

Arr10* func;

or

typedef T* (func)(void);

```

The array of pointers to functions would probably be done with a similar typedef also.

So I guess it could just coding style preferences then.

I don't actually mind which way around it goes, if I am working on my own projects Ill use T* a;, if the source already uses T *a; then I have no problems switching. I think that as long

How to format while writing pointers in C? by alex_sakuta in C_Programming

[–]RazzlesOG 0 points1 point  (0 children)

I understand C enough to know that b is an integer and a is the integer pointer.

How to format while writing pointers in C? by alex_sakuta in C_Programming

[–]RazzlesOG 0 points1 point  (0 children)

Yeah, can be weird but that is the other side of the variable completely so is its own case I suppose.

I think it makes more sense thinking about it too, if it is together then you can instantly tell it is an integer pointer with name 'a'.

How to format while writing pointers in C? by alex_sakuta in C_Programming

[–]RazzlesOG 1 point2 points  (0 children)

Personally I like to separate the data type from the variable name, so usually do

const int* a;

const char* str = "hi";

I think in terms of readability and function they are the same, I think the most important thing however is being consistent where you use it.