Thursday, September 3, 2015
Windows Simple Batch Shutdown Timer
It seems like after every reformat I end up rewriting this timer. It's a simple batch timer for Windows 10, most likely works for other Windows OSs, but I haven't tested. Feel free to post your results! Thought I would put it here in case anyone needed something quick like this. I use it for listening to music before bed. Place the code into a .bat file. I put mine on my Desktop for quick double-click action. Once opened, the sleep timer prompts you for a sleep time (in minutes). Feel free to modify the timer for whatever suits you best!
Monday, August 24, 2015
C++ Command Line Args - Hello World
To start off this blog I'm going to begin with a simple hello world program. I was questioned about command line arguments by a friend. So here's killing two birds with one stone.
A little bit about command line arguments, what are they? Command line arguments are additional strings that you can append to a command when running an application from the command line. These additional segments of information get passed to the application when executed. The program will then decide what to do with the extra data provided. If you've ever used a command line tool like ls, then you might know that you can change its behavior with command line arguments. Here is an example of this:
You can see adding -l and -lh provide the user with a more detailed output.
The example that I have written below takes any number of command line arguments and will output to you how it has interpreted each argument. This example is a good starting point to begin learning how to handle the arguments for an application of your choosing.
Big thanks to gist-it for providing an embedding service for github code. The following instructions were executed on a distribution of Linux. There can be much more information associated with getting a compiler and running it, but here are the basics: Copy the code into a text editor of your choice and save it as a .cpp file. From the command line you can use the g++ compiler to create an executable. Once compiled you can run the application and pass in some command line arguments. Here is a simple example of this process:
Feel Free to post any question you might have, I'm more than happy to get you pointed in the right direction, cheers!
A little bit about command line arguments, what are they? Command line arguments are additional strings that you can append to a command when running an application from the command line. These additional segments of information get passed to the application when executed. The program will then decide what to do with the extra data provided. If you've ever used a command line tool like ls, then you might know that you can change its behavior with command line arguments. Here is an example of this:
The example that I have written below takes any number of command line arguments and will output to you how it has interpreted each argument. This example is a good starting point to begin learning how to handle the arguments for an application of your choosing.
Big thanks to gist-it for providing an embedding service for github code. The following instructions were executed on a distribution of Linux. There can be much more information associated with getting a compiler and running it, but here are the basics: Copy the code into a text editor of your choice and save it as a .cpp file. From the command line you can use the g++ compiler to create an executable. Once compiled you can run the application and pass in some command line arguments. Here is a simple example of this process:
Feel Free to post any question you might have, I'm more than happy to get you pointed in the right direction, cheers!
Subscribe to:
Posts (Atom)

