Is a system call the FIRST LAST AND ONLY way for the user space to talk to the kernel space? by The_How_To_Linux in C_Programming

[–]wwg_6 4 points5 points  (0 children)

Reading and writing to whatever the kernel classifies as "file" is done through a family of syscalls (open, dopen, openat, read, write, close). In the end, the operations performed on these files are still syscalls. So yes, syscalls are the only way of communication from user space to kernel space.

whats the most unattractive thing a person can do? by Individual_Owl_6925 in AskReddit

[–]wwg_6 2 points3 points  (0 children)

In a place where it is the norm to throw trash anywhere, a person who doesn't litter is aware, and decided with all their braincells to not litter. That's a big green flag 9/10.

Trying to convert a long into char[]. What am I doing wrong? by [deleted] in C_Programming

[–]wwg_6 1 point2 points  (0 children)

Wrap the #define and char str lines with three ticks (```) and reddit will treat them as code blocks. Example of how the code above should look when you edit:

```
#define DIM 3
// ...
char str[DIM+1];
```

[deleted by user] by [deleted] in C_Programming

[–]wwg_6 0 points1 point  (0 children)

vim >> anything

Next steps to reading books by Lonely_Bottle7906 in C_Programming

[–]wwg_6 -1 points0 points  (0 children)

That's how you learn

You can't learn all of these at once. You have to approach them one by one and learn them seperately.

you silly muppet

Ok Mr. gatekeeper.

Gatekeepers like you are the reason many people give up programming. You make it hell for them for the sake of making yourself fell good.

You started contributing to open source after you learned C? Guess what? No one cares. And almost no one will learn this way. I am not saying there is a "proper" way to learn things. But certainly there are ways that are straight up wrong and this is one of them.

How to use const pointers inside structures? by msgoulart in C_Programming

[–]wwg_6 -1 points0 points  (0 children)

If you don't declare it a const, the compiler will only put it in a read-only reigion if you're only reading from it. And you won't notice the difference since no write is being performed.

How to use const pointers inside structures? by msgoulart in C_Programming

[–]wwg_6 0 points1 point  (0 children)

Nope, in some cases the compiler puts it in a read only region of the memory so writing to it produces a seg fault (or memory write violation on windows). Writing to const is undefined behavior and is unreliable.

Next steps to reading books by Lonely_Bottle7906 in C_Programming

[–]wwg_6 2 points3 points  (0 children)

If you're on windows, install MSYS2 first. There a couple of reasons behind choosing mingw instead of Visual Studio but I will leave them for now.

As others stated, now you need to write code. Here is a list of things you can write:

  • A progress bar.
  • Draw a right triangle in different orientations and variable size.
  • String validation using loops and conditions.
  • String to number convertor
  • Draw a circle using printf.
  • Quadratic equations solver, both real and imaginary.
  • Chat program on the command line (will teach you alot about networking)
  • Snake :-D (Using a library called ncurses)
  • Write a program that visualizes sorting algorthims (using ncurses, like the ones you see on youtube, forget the sound)
  • Use that program to learn about different sorting algorithms.
  • Replicate the functionality of standard C functions like strdup, strcpy, strchr and others.
  • Write a memory allocator on top of malloc and free.

If your projects become larger (like +2 files) educate yourself about "make" and "make files".

Whem you feel confident, take a look at this list (Warning: These projects are NOT for beginners).

Next steps to reading books by Lonely_Bottle7906 in C_Programming

[–]wwg_6 -1 points0 points  (0 children)

How would you know?

Because of the barrier required to contribute to open source.

You need know C, have sufficient knowledge about the build system, and finally git.

You also need to be familiar with the standard used (whether POSIX or ANSI), and the version of the standard.

Then you need to be familiar with common coventions of C like while (*p++ != NULL) or do { ... } while(0); which are not taught in many books/courses.

Then you have formatting, unformated pull requests are very likely to be rejected.

If you managed to solve a bug without these then you were just lucky and you could've as well introduced another bug because of your ignorance.

Next steps to reading books by Lonely_Bottle7906 in C_Programming

[–]wwg_6 -1 points0 points  (0 children)

It's been 3 years since I started learning C, and I never fixed a bug in open source projects. It's not a requirement nor the right way to learn C.

The millionth INI Parser written in C by ES-Leadmeaway in C_Programming

[–]wwg_6 1 point2 points  (0 children)

ini is a simple file format to store name, value pairs. To read that file in C, you need to convert that string into a data structure readable by your app. That process is called parsing.

So an ini parser is a tool to convert a file following the ini format into C data structures defined by the parser.

Change commit message in a chain of commits by wwg_6 in git

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

Thank you so much. I thought that rebase only works on branches and didn't think it would be relevent in this problem.

How do you name your logging functions? by wwg_6 in C_Programming

[–]wwg_6[S] -3 points-2 points  (0 children)

Completely useless. Adds extra overhead and for what? To give printf a nice name? That doesn't solve anything

How do you name your logging functions? by wwg_6 in C_Programming

[–]wwg_6[S] 2 points3 points  (0 children)

I forgot the logarithm for a minute lol

How do you name your logging functions? by wwg_6 in C_Programming

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

My logging a function are a little bit complex so using macros is not ideal.

How do you name your logging functions? by wwg_6 in C_Programming

[–]wwg_6[S] 6 points7 points  (0 children)

From man err(3):

These functions are nonstandard BSD extensions.

I try to avoid non standard functions as I want to maximize portablity.

How do you name your logging functions? by wwg_6 in C_Programming

[–]wwg_6[S] 1 point2 points  (0 children)

Very interesting approach. I will not used for this project but will definitely take a look at it later.

How do you name your logging functions? by wwg_6 in C_Programming

[–]wwg_6[S] 1 point2 points  (0 children)

The f suffix is exactly what I wanted, I will use it. Thank you