* Upvote this comment if this is a good quality post that fits the purpose of r/Minecraft
* Downvote this comment if this post is poor quality or does not fit the purpose of r/Minecraft
* Downvote this comment *and report the post* if it breaks the [rules](https://www.reddit.com/r/Minecraft/wiki/rules)
----
(*Vote has already ended*)
mintdaniel422025-11-20 18:56
Nice work, you could try to pass the coords as cmd line arguments and just print the output so that it's compatible with copy-pasting
xXxCountryRoadsxXx2025-11-20 19:10
Or you could just use mental math...
adamalshouli962025-11-20 19:28
OORRRR you could not be a jerk and encourage him....
Manos_Of_Fate2025-11-20 19:35
“And then Manos was never seen again.”
BrokenCapsule2025-11-20 20:35
Always gotta have that one joyless redditor don't we
Wave_Table2025-11-20 22:03
bros gonna lose it when he hears about hello world
WW920302025-11-20 22:11
even if OP's program did not exist i would still be pulling out a calculator (despite being a cs student). Have some empathy.
ultrasquid92025-11-20 19:13
Ooh nice! C is a tricky language, learning it is pretty impressive!
One thing I'd recommend doing is making it so the arguments are passed in via CLI flags, rather than having it prompt you for them. You can do this by changing your main function to this:
```c
int main(int argc, char** argv) {
// code here
}
```
From there, just check that the proper number of arguments are there, and you should be good to go! Just note that C considers the program itself as an "argument", so you'll need to check that argc is 1 higher than the number of arguments you want.
kwizzle2025-11-20 23:39
So what exactly does char** do? It's a pointer to a pointer I can tell that much, but how would it be used? I studied C in school but we just did scanf if we needed to get an input. Now that I think of it the argument for scanf was always an address, but how does that translate to a char**?
thronewardensam2025-11-21 00:01
A pointer variable is simply a memory address. We call it a pointer because it "points" to the variable or other data structure at the memory address it stores. Importantly, the pointer is itself a variable just like whatever it points to. A `char*` is a pointer to a character, so a `char**` is **a pointer to a pointer to a character**.
So now you might ask, "why does the main function have a pointer to a pointer to a character?" Remember that a pointer variable is a memory address. Memory isn't cleanly divided into "variables", it's just consecutive bytes of data. If you went to the memory a pointer variable points to you would see the data for the variable you want, and then you would see a ton more data after that where other variables and data are stored.
If a pointer is just a memory address, then why does it need to only point to a single variable? Why can't it point to a bunch of variables in sequence in memory? That's what `char**` does in this instance. The `char**` argument in C main functions is actually a pointer to a *series* of `char*` variables, each of which point to a series of character variables. To express it in higher-level terms, **the** `char**` **argument in a main function is an array of strings.** When the program starts, that array gets filled with any command line arguments you give your program when you run it (ex. `./program arg1 arg2`).
ultrasquid92025-11-21 00:07
In C, a pointer may either be pointing to a single value or to an array. Afaik C doesn't allow you to pass arrays to a function directly, so you need to pass a pointer to that array instead. C also lacks a proper String type, instead just using arrays of chars. `char** argv` is basically an array of strings, and equivalent to Java's `String[] args`.
(note: this may be an oversimplification, typically I program in Rust and am not too well-versed in C's intricacies. If I got something wrong, feel free to correct me)
nybble412025-11-21 00:57
Another way to write the same argument type is `char *argv[]`, an array of `char*` (C-string) values with an unspecified length. This format can avoid some confusion over multiple levels of pointers but it's all the same to the compiler.
The number of strings in the array is given by the `int argc` argument, and the array itself is also terminated with a NULL pointer after the last string.
There are technically ways to pass small fixed-length arrays by value (e.g. by wrapping them in a structure) but they aren't often used. If you pass an object of an array type to a function it will be converted into a pointer automatically. For the most part (aside from the `sizeof` operator) the array and pointer forms are interchangeable, and most operations on arrays actually work on the implied pointer value. For example `array[index]` is just syntactic sugar for the pointer arithmetic `*(array+index)`, to the point that you could even write `index[array]` and get the same result.
thewizarddephario2025-11-21 02:53
Sometimes pointers are arrays in C. A `char*` is how C represents Strings (an array of chars with the last element being the nul character '\0'). So argv really is a string array with the length of the string array begin the first argument (`argc`)
kwizzle2025-11-21 12:23
Ah yes, and array elements are just addresses. There's something fun about having to be aware of all these things in good old C.
QuintBrit2025-11-20 19:15
Remember to finish your `printf`s with `\n` to ensure the next line (including the shell prompt) is on a new line!
notredditbastardson2025-11-20 19:22
Great work! Make sure to add a `\n` to your final `printf` statement so that it creates a line break.
Judas4192025-11-20 19:31
Nice start! Don't forget the Z coordonate!
edmundusx2025-11-20 19:51
The numbers 😔
gianpi6122025-11-20 20:28
The numbers, Mason, what do they mean?
Mr_Koltuk2025-11-20 19:51
in an era that ai took all over the place. seeing something like this gives me determination. (oh wrong referance :D)
onm32025-11-20 20:31
Great job! how did i not think of doing this before in python... Anyway keep working on C i believe in you!!!!
also to those who want a python version (i just made it)
convert = input("Convert to nether coordinates or overworld coordinates? ( n / o ): ")
x = float(input("Enter x coords: "))
z = float(input("Enter z coords: "))
if convert.lower() == 'o':
print(f"Coordinates are: ({x}, {z}) converted to overworld coordinates: ({x*8:.2f}, {z*8:.2f})")
elif convert.lower() == 'n':
print(f"Coordinates are: ({x}, {z}) converted to nether coordinates: ({x/8:.2f}, {z/8:.2f})")
else:
print("Invalid option selected. Please choose 'n' for nether or 'o' for overworld.")
CelDaemon2025-11-20 20:41
Floats actually aren't really necessary, you're fine just using integer division.
onm32025-11-20 20:50
yeah but i think i will keep it just in case someone enters a decimal anyway... and i can always put a try except statement to catch someone entering a decimal if i happened to use int but I want to keep the code relatively easy to read for begineers.
CelDaemon2025-11-20 20:40
Nice job with learning C!
One tip I do want to give is that you should ensure that your lines end with a newline, having the prompt be offset is generally not a nice experience.
AleksandrNevsky2025-11-20 20:52
Baby steps but be proud of it. And you're using C. It's the language of champions.
Un-revealing2025-11-20 20:57
Congrats!
Now make a program to calculate strong hold coordinates, with 2 eyes of ender.
andr3wsmemez692025-11-20 22:32
I looked into what it would take to do that, yeah im nowhere near that level......yet
I now want to turn this into a program that can be used for multiple minecraft related things, nether coords, stronghold triangulation, heck maybe even a random seed generator?
I'm thinking of calling it MCC but that seems to be taken...
Un-revealing2025-11-21 08:24
well keep us updated with your new programs
AssistanceLegal75492025-11-20 21:05
use f3+c to out it in your Clipboard from Minecraft, paste it with rightclick, let the calculation Outcome back in the Clipboard. easy as that
AndreasMelone2025-11-20 21:22
Yay divided by 8
05-nery2025-11-20 21:28
Good job! Keep the programming up
Lechatdu1362025-11-20 22:07
Is Kris deltarune your cursor
andr3wsmemez692025-11-20 22:19
yes
DoknS2025-11-20 22:09
Wow, you can divide by 8. I miss the old, stricter moderation
Gametron132025-11-20 22:28
Boo.
Sure this is a simple script, but it’s a great learning exercise for someone just starting out with a language. There’s a lot of setup required to have a script simply “divide by 8” including gathering user input, writing to a variable, apply operations to said variable, and then reading the variable while displaying it to the user.
I’ve been programming for a few years and the scripts I made when starting out weren’t the most glamorous things, but they all taught me stuff. All my knowledge and practice led me to the most recent thing I created; which is a game engine that displays ASCII graphics to the console application and allows for very simple rudimentary games to be created with various bells and whistles like colored sprites and stat bars that can display values like health or experience points. I even made a game using that engine. I imagine this guy can also get to that level with a few more years of practice.
DoknS2025-11-20 22:31
This isn't a programming subreddit, and if it was posted on one, it would be removed instantaneously. What's stopping everyone here from making a post about it but in a different programming language? Do you think print(int(input())/8) is high quality content?
Gametron132025-11-20 22:35
This isn’t an art subreddit either and yet you’ll see posts of people who make plushies or drawings related to Minecraft.
It’s a multimedia subreddit related to Minecraft where people post things related to Minecraft.
loadedslayer2025-11-20 22:53
That objectively requires more skill if done right, i say this as a programmer
DoknS2025-11-21 06:28
Yeah, this subreddit's fucked
BeautifulOnion81772025-11-20 22:12
now make it work backwards! (multiply instead of divding)
MrCubite2025-11-21 00:18
this is peak, keep learning :)
jordankothe92025-11-21 01:45
If you want to take this to the next level you should allow your program to accept and parse the output of f3+c. This contains the coordinates and the current dimension. from there you could determine your overworld location from the nether and vis versa with a simple copy paste
This is example output. I had to add a backslash to prevent reddit from changing it.
"/execute in minecraft:overworld run tp \\@s 173.30 67.00 431.13 -68.12 3.90"
Key-Astronaut18832025-11-21 03:13
Is that a Kris cursor?
noxar_ad2025-11-21 11:58
Nice work, be sure to the end on a newline as to avoid the writing the next command on the same line.
karkko12025-11-21 12:46
You made a glorified and more complicated calculator. Congrats.
SuperGamer6503332025-11-21 17:37
No one is going to notice him typing 67 for the x coordiate. Anyways nice work.
TheLoneRipper12025-11-21 19:27
now make it so that you can input a string with xx,yy,zz format and just put it in the command line and automatically print the result. then make it a plugin in minecraft
Commentaires
* Downvote this comment if this post is poor quality or does not fit the purpose of r/Minecraft
* Downvote this comment *and report the post* if it breaks the [rules](https://www.reddit.com/r/Minecraft/wiki/rules)
----
(*Vote has already ended*)
One thing I'd recommend doing is making it so the arguments are passed in via CLI flags, rather than having it prompt you for them. You can do this by changing your main function to this:
```c
int main(int argc, char** argv) {
// code here
}
```
From there, just check that the proper number of arguments are there, and you should be good to go! Just note that C considers the program itself as an "argument", so you'll need to check that argc is 1 higher than the number of arguments you want.
So now you might ask, "why does the main function have a pointer to a pointer to a character?" Remember that a pointer variable is a memory address. Memory isn't cleanly divided into "variables", it's just consecutive bytes of data. If you went to the memory a pointer variable points to you would see the data for the variable you want, and then you would see a ton more data after that where other variables and data are stored.
If a pointer is just a memory address, then why does it need to only point to a single variable? Why can't it point to a bunch of variables in sequence in memory? That's what `char**` does in this instance. The `char**` argument in C main functions is actually a pointer to a *series* of `char*` variables, each of which point to a series of character variables. To express it in higher-level terms, **the** `char**` **argument in a main function is an array of strings.** When the program starts, that array gets filled with any command line arguments you give your program when you run it (ex. `./program arg1 arg2`).
(note: this may be an oversimplification, typically I program in Rust and am not too well-versed in C's intricacies. If I got something wrong, feel free to correct me)
The number of strings in the array is given by the `int argc` argument, and the array itself is also terminated with a NULL pointer after the last string.
There are technically ways to pass small fixed-length arrays by value (e.g. by wrapping them in a structure) but they aren't often used. If you pass an object of an array type to a function it will be converted into a pointer automatically. For the most part (aside from the `sizeof` operator) the array and pointer forms are interchangeable, and most operations on arrays actually work on the implied pointer value. For example `array[index]` is just syntactic sugar for the pointer arithmetic `*(array+index)`, to the point that you could even write `index[array]` and get the same result.
also to those who want a python version (i just made it)
convert = input("Convert to nether coordinates or overworld coordinates? ( n / o ): ")
x = float(input("Enter x coords: "))
z = float(input("Enter z coords: "))
if convert.lower() == 'o':
print(f"Coordinates are: ({x}, {z}) converted to overworld coordinates: ({x*8:.2f}, {z*8:.2f})")
elif convert.lower() == 'n':
print(f"Coordinates are: ({x}, {z}) converted to nether coordinates: ({x/8:.2f}, {z/8:.2f})")
else:
print("Invalid option selected. Please choose 'n' for nether or 'o' for overworld.")
One tip I do want to give is that you should ensure that your lines end with a newline, having the prompt be offset is generally not a nice experience.
Now make a program to calculate strong hold coordinates, with 2 eyes of ender.
I now want to turn this into a program that can be used for multiple minecraft related things, nether coords, stronghold triangulation, heck maybe even a random seed generator?
I'm thinking of calling it MCC but that seems to be taken...
Sure this is a simple script, but it’s a great learning exercise for someone just starting out with a language. There’s a lot of setup required to have a script simply “divide by 8” including gathering user input, writing to a variable, apply operations to said variable, and then reading the variable while displaying it to the user.
I’ve been programming for a few years and the scripts I made when starting out weren’t the most glamorous things, but they all taught me stuff. All my knowledge and practice led me to the most recent thing I created; which is a game engine that displays ASCII graphics to the console application and allows for very simple rudimentary games to be created with various bells and whistles like colored sprites and stat bars that can display values like health or experience points. I even made a game using that engine. I imagine this guy can also get to that level with a few more years of practice.
It’s a multimedia subreddit related to Minecraft where people post things related to Minecraft.
This is example output. I had to add a backslash to prevent reddit from changing it.
"/execute in minecraft:overworld run tp \\@s 173.30 67.00 431.13 -68.12 3.90"