r/cprogramming • u/TurtleSlowRabbitFast • 21d ago
Would learning C as my first programming language also be useful for picking up other languages later on? What are your thoughts on this course?
Wanting to learn C as an intro into software engineering. I know it’s low level and I’d like to eventually switch over to high level languages such as JS/TS, Java, and GO.
Does the “The Complete C Programming Bootcamp” course by Byte Garage be a good choice to learn from?
35
Upvotes
View all comments
Show parent comment
2
u/Previous-Box2169 20d ago
Oh thanks, this sounds like something I absolutely need to understand now in my early C days. Can you explain why, in the pointer declaration, the * binds to the pointer's name and it's not part of the type. In my understanding, the pointer type is always declared through the "type*" syntax (as in void*), so it makes sense to me that when I declare a pointer I would type "type* ptr = &a".
But I keep seeing "int ptr = &a" so it MUST be right and there must be something I still lack in my acknowledgement, which currently goes like this: "I'm taking the address of variable a and putting it inside the pointer ptr, which is a pointer to an int (from the compiler point of view)", which is coherent with the "int ptr = &a" syntax. While typing "int *ptr = &a" would mean "Take the address of variable a and set it as the content of the variable pointed by ptr" (what dereferenciating means), which basically creates a pointer to a pointer because you're putting an address inside the variable pointed by a pointer. But you're not actually putting the address of a inside the variable pointed by ptr, you're putting it inside ptr itself because you want ptr to contain an address (that's what being a pointer means). This completely brokes my understanding of a pointer, so I would appreciate if you could make clear to me why getting used to use the "type *ptr = &a" syntax would be better.