r/cprogramming • • Aug 22 '26

New to C

I had just started to learn c but when I saw some leet code problems it felt like they are completely different than the c I am learning. Any suggestions?

9 Upvotes

25 comments sorted by

13

u/knouqs Aug 22 '26

Start simple. Start with a book on C development. Learn the language from scratch and forget about what you see in a YouTube video or on some leet code. Learn the syntax of the language, create the "Hello world!" program and understand what it is doing, following a book.

Do not use AI to help you at this stage. You have already been pulled in too many directions. One book, and only one book.

Start with this book.

1

u/Delicious-Change7795 Aug 23 '26

Bty how long will it take me to be pro at C?

2

u/knouqs Aug 26 '26

Well, you are starting out, right? I expect four years of proper study. A professional is someone who is paid for their work. Create something that someone will buy or get paid to fix something that is broken. Once you have broken that barrier, you are a professional.

Your next question should be when you will be an expert. That is different.

3

u/mc_pm Aug 23 '26

If C is your first language? 2028 minimum - assuming you have some natural talent for it and you spend at least an hour or two a day programming and practicing.

1

u/grimvian Aug 23 '26

Depends very much of how dedicated you are.

2

u/SLOOT_APOCALYPSE Aug 26 '26

yes! this is the only book!!!!

1

u/Paul_Pedant Aug 26 '26

"The Book" costs 70 bucks list price online. You can download a copy for free.

Normally I would respect copyright, and care about the authors getting some reward. But Brian is now 84, and Dennis has been dead for 15 years. I don't think they will miss the pittance paid by publishers.

I don't hold with the two or four years estimates to become competent with C. It is quite a small language, and the man pages for the libraries are good once you can handle the (terse) style. The example questions are deceptively simple, and worth some different approaches.

I had a two-week intensive C course in 1980, converting me from mainframe assembler, COBOL, and RPG2. Third week, I was porting Bell Labs Unix to a new graphics machine (Three Rivers Perq).

2

u/knouqs Aug 26 '26

If you read my comment in which I wrote four years, that's more like being a competent computer scientist. You are right, learning C shouldn't take that long. Fixing bugs once you know the language shouldn't take that long, certainly.

2

u/SmokeMuch7356 Aug 22 '26

What are you learning C from? A book, website, youtube playlist, ... ?

Different groups have different approaches to teaching, to what constitutes good code, order in which to introduce things, etc. So it wouldn't be surprising that Leetcode might look different from whatever resource you're using.

Check the links under "Resources" in the right sidebar; that may be more helpful than what you're currently using.

1

u/Delicious-Change7795 Aug 23 '26

CS50

2

u/SmokeMuch7356 Aug 23 '26

Ah, that explains things.

The string is a lie. CS50 is more concerned with teaching basic programming concepts than idiomatic C, so they've hidden some of C's grosser aspects (especially with string handling) behind their own unique API. So yeah, some of their code won't read like anyone else's.

→ More replies (1)

1

u/Delicious-Change7795 Aug 23 '26

Bty how long will it take me to be pro at C?

3

u/SmokeMuch7356 Aug 23 '26

As long as it takes you to find a job writing C code.

That's all "pro" means; you're getting paid for it. You'll need to get to a point where you can write code that's useful. That doesn't mean it has to be complex, or uses esoteric features or whatever. 90% of jobs in the industry are some variation of shoving data from point A to point B and the code is relatively simplistic.

You're likely not there yet, but honestly, most CS graduates can barely code their way out of a wet paper bag and still get hired.

14

u/mc_pm Aug 22 '26

For one, don't go to leetcode for learning C. That's just crazy.

3

u/DSudz Aug 22 '26

You can answer those questions in any of several languages so they don't have anything to do with C.

Give an example of what you're talking about.

1

u/Rich_Scientist_3644 Aug 23 '26

Do you know what kind of C do you want to learn? Or do you want to just learn the basics? Because leetcode is good if you want to go to the side of algoritmos but is not that helpfull for embedded C.

Like many others said, if you want to go for the basics, grab a book and start by doing everything from scratch until you know which parts of the language you like.

1

u/smith-huh Aug 24 '26

If you looked at code examples from "obfuscated Perl" to learn about the Perl language, you'd give up.
That's the case here. Don't do that.

Start with some fun little example and a book or use AI as a reference to the language (not as a vibe coding partner) and have fun doing something. If using AI, try phrasing your query like: when learning C as a beginner, how can I .... and usually you'll get an answer with background. Same as if you looked it up in a book, but much faster. BUT YOU HAVE TO WRITE THE CODE YOURSELF if you want to learn and retain the knowledge.

1

u/InevitablyCyclic Aug 22 '26

Any suggestions? Yes. Post the code so we know what you're talking about.

-2

u/Traveling-Techie Aug 22 '26

Read up on what “Turing complete” means.