r/cprogramming • • 15h 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 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!

13 Upvotes

14 comments sorted by

12

u/zhivago 15h 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.

5

u/JohnVonachen 15h 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.

3

u/jombrowski 14h ago • Bravo

Crash course:

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

1

u/jayylien 4h ago

Hah. I see what you did there.

1

u/nacnud_uk 10h ago

1

u/smichaele 4h ago

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

1

u/nacnud_uk 4h 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/Anonymity6584 7h ago

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

1

u/Faalentijn 7h 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/Gold-Part4688 7h 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 46m ago

Learn basic syntax and write a program like a webserver

0

u/Brother__Mouzone 15h 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 8h 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