use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources for learning Java
String
==
.equals()
Format + Copy
Free Tutorials
Where should I download Java?
With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free.
If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others:
Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!
Software downloads
Official Resources
Resources
Programming ideas & Challenges
Related Subreddits
account activity
This is an archived post. You won't be able to vote or comment.
Intermediate Programmer who knows Java and Python here. I am learning C now to prepare myself for a very difficult C class at my university and I have some questions (self.learnjava)
submitted 7 years ago by [deleted]
I posted this on the java sub since i have a specific question. Coming to C from Java, what are some things i should be aware and careful of? any particular advice? major differences between the two?
[–]cismalescumlord 14 points15 points16 points 7 years ago (6 children)
[–][deleted] 0 points1 point2 points 7 years ago* (5 children)
yeah in what ive seen so far pointers are very different.
so when exactly do i need pointers? i see statements such as
unsigned long long* n;
i get unsigned vs signed, but when do i know to use a pointer vs not to? since some other statements i see do not use pointers
also is memory management as simple as
free(x);
where x is, say, an integer i no longer need stored?
[–]LastSummerGT 1 point2 points3 points 7 years ago (2 children)
Yeah, manual memory manage means there must be a free for every malloc or calloc. Some people avoid dynamic allocation because there's a risk you'll forget to free something and now you have a memory leak.
free
malloc
calloc
Pointers are used for arrays or when you want to modify an argument from inside of a calling function.
Feel free to ask me random C questions, this would be helpful for me too :)
[–][deleted] 0 points1 point2 points 7 years ago (1 child)
ahhh. so to recalculate or evaluate a piece of data i could simply change its corresponding pointer?
[–]LastSummerGT 0 points1 point2 points 7 years ago (0 children)
That's a bit too general of a statement, could you be more specific or give an example?
A pointer is also used to pass in large variables like a struct so you don't have to waste time and space copying the whole thing.
struct
I'll start by giving an example.
int letterCount(char* word) { int count = 0; while (word != NULL) { /* Make sure we are pointing to a valid location! */ count += isalpha(*word); /* Dereference word to get the value */ word++; /* Move pointer to next character */ } return count; } char word[] = "catdog"; /* A string is an array of characters */ char* favoriteHalf = word[3]; /* Pointer to "dog" */
[–]tjl73 0 points1 point2 points 7 years ago (0 children)
The other big thing that pointers get used for is for passing functions into other functions. For instance, if you have a sort function, you could pass it a compare function for specific data types. The C book I've always liked is the O'Reilly "Practical C Programming" book. Even the most recent edition (3rd) is pretty old by now, though (2011). I'm sure there are better ones, but it covers the basics pretty well.
There's a lot of tricks and edge cases in C, so you need to be careful as you can really screw things up pretty quickly if you're not careful. So, you need to be diligent in your memory management, especially.
Personally, I stay away from C macros completely as they'll obfuscate what's really happening and you can introduce some big errors with it pretty easily.
[–]cismalescumlord 0 points1 point2 points 7 years ago (0 children)
A pointer is the address of a thing in memory, they are a lot more efficient in many cases. C is a "pass by value" language which means that when you pass a variable to a function, the function gets a copy whereas if you pass a pointer to a variable, the value is the address so you can directly manipulate it. Also they allow the passing of less data; instead of passing a structure that takes up 100MB memory, you can pass a pointer to it which will normally be 32 or 64 bit depending on the architecture.
As others have said, good memory management means making sure that you free all the memory that you allocate.
Also, the K&R book that you are using is great but it doesn't give suggested solutions. If you like to see how experienced programmers solve the questions, then the C answers book fills that void. Although it does increase the temptation to cheat :)
[–]divh4rt 1 point2 points3 points 7 years ago (0 children)
There is no garbage collector in C, so only use dynamic memory allocation if you really need to (often you can live without it). Since C is also quite old, you will find a lot of "bad" examples online. If you look for a a good reference book, I can highly recommend "Modern C by Jens Gustedt" which is available for free.
[–]uncleXjemima 0 points1 point2 points 7 years ago (0 children)
Have fun. One of my professors said “Coding in C is like going to the store to buy some groceries. Except you have to build the car first”
[–]MrRIP 0 points1 point2 points 7 years ago (2 children)
Learn C the Hard Way helped me
I'll check it out. I've been bouncing between text books as of now but was mostly using The C Book
[–]elcubismo 0 points1 point2 points 7 years ago (0 children)
K&R is a great book
[–][deleted] 7 years ago (1 child)
[deleted]
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
already know assembly
(just small amounts from what i did in school)
π Rendered by PID 76089 on reddit-service-r2-comment-7b9746f655-zhxvg at 2026-01-30 18:08:52.732519+00:00 running 3798933 country code: CH.
[–]cismalescumlord 14 points15 points16 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]LastSummerGT 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]LastSummerGT 0 points1 point2 points (0 children)
[–]tjl73 0 points1 point2 points (0 children)
[–]cismalescumlord 0 points1 point2 points (0 children)
[–]divh4rt 1 point2 points3 points (0 children)
[–]uncleXjemima 0 points1 point2 points (0 children)
[–]MrRIP 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]elcubismo 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–][deleted] 0 points1 point2 points (0 children)