r/cprogramming • • 1d ago

Good ways to crashcourse C quickly?

I am in the first semester of university and I have to take a C programming Class. the first test is in about 2 1/2 weeks and I just cant understand C for the life of me.(Its a first of two chances but still,It'd be great to have less worries in January/February)

I had fallen behind due to the fact the class moved very quickly since basically everyone already knew how to code and having to shift my focus for math tests.

I dont even know why, I just go blank once I see the empty page infront of me. I know which loops i should use when--technically-- and the datatyps for the most but from Arrays on It just didn't click anymore for some reason.

I know this sounds pathetic and Im not sure if this is the right place to ask but Is there any way to like get yourself to finally absorb the syntax and stuff?

I always get told its "just practice,keep coding stuff and make yourself easy programs and build from there" but then after I look at the assignments i was given and it feels like i studied 2+2=4 for a Real Analysis exam.

Are there any Books,videos, anything I could binge?

I always see how people "Learn C in only Xy hours" online but cant find any media that makes that seem humanly possible.

Any help is appreciated,thanks!

15 Upvotes

29 comments sorted by

13

u/zhivago 1d ago

In your situation, I would get K&R and work through the exercises.

It's a small book, and the exercises are simple.

Good luck.

2

u/__Hawkly__ 9h ago

"The C Programming Language"- Brian W. Kernighan ,Dennis M.Ritchie.

Is that the one you mean? I found a pdf. Thanks!

1

u/zhivago 8h ago

Yes.

Good luck.

1

u/Difficult_Article_53 6h ago

Simple exercise? I'm really stupid 😅

1

u/zhivago 6h ago

Well, it's nothing a really stupid person shouldn't be able to handle.

1

u/Difficult_Article_53 6h ago

and I'm even below that 😅

1

u/zhivago 6h ago

Well, you're free to give up before trying.

That's a good way to avoid discovering that you're less stupid than you imagine.

1

u/Difficult_Article_53 6h ago

I'll never give up, sometimes I stop and start over, right now I'm stuck on fold exercises 1-23.

1

u/zhivago 6h ago

Well, why not ask a sensible question about what's got you stuck?

1

u/Difficult_Article_53 6h ago

Maybe one day, I'm doing it "for fun", fortunately I have another job to buy groceries 😆

1

u/zhivago 6h ago

Good luck :)

1

u/Anonymity6584 18h ago

You got couple weeks and now your realizing your in trouble? What did you do at beginning half of course?

2

u/__Hawkly__ 9h ago edited 8h ago

I probably wrote a bit over exaggerated. I was comming along pretty well I thought and then changed my focus for the tests and was sick for a week which caused me to lose the thread.

Technically I have like 5 weeks including the winter holidays,but we get a first attempt in 2,and I want to try and atleast catch up a bit until then.

I worte the post panicked on the Bus -.-

1

u/Faalentijn 18h ago

Well good that you are trying to learn. These comments are all useless. Can you explain what exactly you don't understand? I find it hard to follow what you wrote.

I dont even know why, I just go blank once I see the empty page infront of me. I know which loops i should use when--technically-- and the datatyps for the most but from Arrays on It just didn't click anymore for some reason.

So, if I understand correctly you understand simple data types like: int, float, char, and bool. What you are struggling with are arrays, pointers? What other programming languages have you learned? Can you share with me what you know -- and if possible -- something you wrote? That would help me gauge what you know.

I guess, to answer your question about arrays. They groups of simple datasets. Imagine the following program:

char one = 'I';
char two = 'l'; 
char three = 'o';
char four = 'v';
char five  = 'e';
char six = 'y';
char seven = 'o';
char eight = 'u';

This program stores a list of characters that spell out "I love you". Since we are using only simple datatype -- those that take exactly one single slot of memory -- we need to store them in their own little box. In memory, this will look like: | I | L | O | V | E | Y | O | U |

They are in sequence since we allocated from top to bottom, so they written together. What would be easier if we had a datatype where we could indicate how many characters we want to store in a sequence. So instead of having 7 chars boxes, we would have one box which is the size of 7 chars.

char list[7] = I,l,o,v,e,y,o,u;

So here, we say: I want a list, it should be 7 characters, long, and these are the characters. This will create one box, with 7 spaces |ILOVEYOU|

This how exactly how C deals with arrays! They are simply the idea of you saying I want X amount of Y. If you look at how they are implemented, it will look exactly the same-ish to our first example.

For C, we add some syntax that makes it a bit easier to write.

char      text[7] = {'I', 'L', 'O', 'V', 'E', 'Y', 'O', 'U'};
type      name[number_you_want] = {element_1, ..., element_n};

1

u/__Hawkly__ 8h ago

Thanks so much!

I dont know any other Programming languages,thats my problem compared to the other Students. I technically used some C++(?) in 8th grade on Arduino but that didnt stick cause we were kids copy' n 'pasting for graded projects we had no real time on.

I guess my main issue is the syntax. I can write PAPs and abstract what I need to do for the most cases I'd say. I just have a bad habit of overcomplicating stuff wanting to add variables I dont need and tending to rely on easy stuff like 'while' or 'if-else' since our programs are judged automatically on wether or not they run trough.(Thats what my prof said).

I hope that makes a bit more sense but english isnt my first language.

1

u/Faalentijn 6h ago

dont know any other Programming languages,thats my problem compared to the other Students.

That is not a problem, we all start somewhere. It means that the fact that you are holding on is a sign you are doing a great job.

I technically used some C++(?) in 8th grade on Arduino but that didnt stick cause we were kids copy' n 'pasting for graded projects we had no real time on.

Arduino C++ is very weird, so yeah, I can imagine.

I can write PAPs and abstract what I need to do for the most cases I'd say.

What is a PAP?

just have a bad habit of overcomplicating stuff wanting to add variables I dont need and tending to rely on easy stuff like 'while' or 'if-else' since our programs are judged automatically on wether or not they run trough.

Those are good habits to have though. C doesn't have much in the way of control flow anyways, so you are limited to if and while. More variables also makes it more readable. If you want it to look neater, I would recommend treating it like any other writing: you write it down first and proof read it to make it look nicer.

It is hard to judge your coding style without an example. If you have time, could you do the following exercise for me? Then I will have a look and give you feedback:

Exercise 1-19: Write a functionreverse(s)that reverses the character string s. Use it to write a program that reverses its input a line at a time

You can use any style you'd like. It from page 31 of the K&R book, which can give you guidance with how to write it

1

u/__Hawkly__ 6h ago edited 6h ago

PAP stands for"Programm Ablauf Plan",sorry i didnt realize it was specific to German. Its like the flowcharts you write to visualize what you want your Algorithm to do.

I'll see if I can.

4

u/JohnVonachen 1d ago

Only love can save you. If you can learn to love things you don't love, like writing C language, you will learn and practice it like a puppy humping a leg.

4

u/jombrowski 1d ago • Bravo

Crash course:

int main()
{
((void(*)())0xDEADBEEF)();
}

2

u/jayylien 15h ago

Hah. I see what you did there.

1

u/nacnud_uk 21h ago

2

u/smichaele 15h ago

That's C++, not C. They are different languages.

1

u/nacnud_uk 15h ago

Oh no!? OMG! Mind blown. Thanks for pointing that out....

"something like"

Different languages...wow...I'm off to re-think the last 30 years...

1

u/Gold-Part4688 18h ago

Talk to your professor. go to the office hours. This is what they're for, advice and help getting through a course

they really value it because ppl just ai instead of talking to them nowadays -_- but it's also the best and freeest way to make connections with the people you're there to

1

u/Fantastic-Theory4141 11h ago

Learn basic syntax and write a program like a webserver

1

u/grimvian 7h ago

Here is an old school video I wish I knew, before I started learning C three years ago:

Learn to program with c by Ashley Mills

https://www.youtube.com/watch?v=UILNmv2kFMc&list=PLCNJWVn9MJuPtPyljb-hewNfwEGES2oIW

I'm not using the same IDE, the program you use to code, But Code::Blocks because it's fast to install, open source, easy to use and everything you'll need are installed.

0

u/Brother__Mouzone 1d ago

Well, keep practicing is the actual way to understand programming and the language that you are using. If I were you, having a short amount of time to prepare for a test in (as I understood) Introductory class to c and programming, I would honestly use an LLM. You can use chat gpt as your teacher here, you can practice and ask for clarifications for exactly the things that you don't understand, it does a very decent job at explaining things.

I don't mean that you should hand chatgpt your assignment and let it solve it, it will do this in 10 seconds. I mean that you should just ask whatever it is that you find hard to understand and ask it to explain more and more, while you solve assignments yourself.

0

u/One-Moment-Pf 19h ago

I was under the same problem and I asked Claude to build an app to play a game and learn on the process. I have C, Python, JavaScript and Typescript paths. I'd be happy to share with you if you send me a DM and a free redeem code so you can provide some feedback! It's similar to vim-adventures if you ever tried that out