Anyone use the Windows command prompt?

  • Thread starter m0bius
  • Start date
  • Tags
    Windows
In summary, the conversation revolves around the topic of learning C++ and using the command prompt to compile and run programs. The participants discuss the advantages of using the command prompt, such as its use for diagnostics and running batch files. They also mention different IDEs and tools that can be used for programming in C++, including Microsoft Visual Studio, Eclipse, and cygwin. The conversation also touches on a specific issue with an IDE and how to solve it. Overall, the conversation provides helpful information and recommendations for learning and using the command prompt in C++ programming.
  • #1
m0bius
15
0
Hey all, I decided to start learning some C++ and my book mentions compiling and running programs from the command prompt. I have taken a few classes in computer science, but those dealt mainly with java, along with some algorithms and data structures. Even though I have used computers since I was probably 6, I know nothing about the inner workings of them or how to use the command prompt. After some testing I was finally able to run a program from the command prompt, but the whole process seems very inefficient. Is there some advantage to using the command prompt or a point in learning how to use it?

So let's say I'm trying to compile my C++ program called prog1.c in the prompt. All the help online seems to require the use of Visual C++, but I'm using Code::Blocks for my compiler/IDE. I'm not even sure if I can do what I want in the prompt. Can you compile prog1.c, choose a new file extension for the compiled version, choose a folder to save it in, then run that file all using the prompt? I know I can do this easily through the Code::Blocks IDE but I'd like to learn how to use the prompt. Thanks for any help.

m0bius
 
Technology news on Phys.org
  • #2
Nowadays I use the Windows command prompt mostly as a shortcut to various programs.
Furthermore, there's a couple of diagnostics that should be run from the command prompt, such as:
C> netstat
C> ping google.com
C> ipconfig /all
to diagnose networking problems.

To program in C++ I would definitely recommend a graphical IDE interface.
For Windows that would be Microsoft Visual Studio, or if you can't get it, I can recommend Eclipse (for which you'll need cygwin).

However, if you want a useful command prompt I can recommend cygwin (http://www.cygwin.com), which basically is "linux in Windows".
This is because the linux command line is very powerful with all the tools that come with it.
This includes a command-line C++ compiler (g++), which is used by Eclipse if you install that.

[edit]Btw, I am unfamiliar with Code::Blocks.[/edit]
 
Last edited:
  • #3
MS also has a more powerful CLI called, IIRC, PowerShell.

I haven't used it much; I do all my serious stuff on Linux.
 
  • #4
In the case of Visual Studio, you have the option of clicking on start / programs / visual studio ... / tools / visual studio command prompt, or ... visual studio x64 cross tools command prompt. This will let you manually compile programs and run them from a dos console window, just like going back to the days of msdos.

Even in the msdos days, there were window like IDE's like Borlands Turbo products, and Microsoft's programmwers workbench.

As far as using command prompt in general, I use it a lot to run batch files, such as a batch file to backup save files that may be scattered in different directories, for a game as I go through it's career mode, or to backup "favorites" and email .dbx files, using some command line compression utility that creates .rar or .zip files. I also have a collection of old command prompt programs that I sometimes compile and run from a dos console window.
 
  • #5
Hey, thanks for the replies.

I like Serena said:
For Windows that would be Microsoft Visual Studio, or if you can't get it, I can recommend Eclipse (for which you'll need cygwin).

I used Eclipse for Java, but when I tried to find a way to program C++ in Eclipse I couldn't figure out how to get it to work for some reason. I'd like to use Eclipse for both Java and C++ and be able to swap languages between the two easily. I don't remember reading about cygwin, although I've found some stuff about it online.

On a side note...I can't get this simple code to do what it should :

Code:
#include <iostream>
int main()
{
    std::cout << "Enter two numbers:" << std::endl;
    int v1, v2;
    std::cin >> v1 >> v2;
    std::cout << "The sum of " << v1 << "and " << v2 << "is " << v1 + v2 << std::endl;
    return 0;
}

All I get is "Nothing to be done" from the IDE. I copied it directly from the book so I think it's something wrong with the IDE, but I just want to make sure.

Thanks,
m0bius.
 
  • #6
m0bius said:
Hey, thanks for the replies.



I used Eclipse for Java, but when I tried to find a way to program C++ in Eclipse I couldn't figure out how to get it to work for some reason. I'd like to use Eclipse for both Java and C++ and be able to swap languages between the two easily. I don't remember reading about cygwin, although I've found some stuff about it online.

On a side note...I can't get this simple code to do what it should :

All I get is "Nothing to be done" from the IDE. I copied it directly from the book so I think it's something wrong with the IDE, but I just want to make sure.

Thanks,
m0bius.

The problem will be that you did not install the Eclipse CDT (C/C++ Development Tooling) plugin, which you need to develop in C++.
I found this page that explains how to do it:
http://www.codeproject.com/KB/tips/CPP_Dev_eclipse_CDT.aspx

Note that it also describes you need to install the MinGW package, which contains the actual C++ compiler.
With this one you won't need cygwin.
 
  • #7
m0bius said:
Hey all, I decided to start learning some C++ and my book mentions compiling and running programs from the command prompt. I have taken a few classes in computer science, but those dealt mainly with java, along with some algorithms and data structures. Even though I have used computers since I was probably 6, I know nothing about the inner workings of them or how to use the command prompt. After some testing I was finally able to run a program from the command prompt, but the whole process seems very inefficient. Is there some advantage to using the command prompt or a point in learning how to use it?
I'm curious to know specifically what you found "inefficient" about the command line...

The command line is a powerful tool. That's why it continues to be shipped with every commercial operating system, even including MS Windows and MacOS X. A lot of useful, powerful but legacy tools exist as command line programs so it's useful just for that...

...but it's useful for so much more than that. Command line programs have a very simple and thus standard input and output method: text. This allows for the chaining of commands. That is to say, you can use the output of one program as the input of another. This obviously lends greater functionality to an otherwise disparate collection of programs. It is also useful for automating tasks.

If your program has minimal user interaction, it may be much simpler to implement it as a command line program. This is especially useful if you're learning to or teaching someone how to program. They can concentrate on the fundamental concepts without being distracted by the complexity of GUI programming...

So let's say I'm trying to compile my C++ program called prog1.c in the prompt. All the help online seems to require the use of Visual C++, but I'm using Code::Blocks for my compiler/IDE. I'm not even sure if I can do what I want in the prompt. Can you compile prog1.c, choose a new file extension for the compiled version, choose a folder to save it in, then run that file all using the prompt? I know I can do this easily through the Code::Blocks IDE but I'd like to learn how to use the prompt. Thanks for any help.
You know, you don't have to write command line programs using the command line. I'm sure any IDE can compile a command line program and even run it in its debugger!

Typically, if you are compiling from a command line interface, you run a make file (or whatever equivalent your system has). It's a script that executes a list of commands (or a requisite subset thereof) that are necessary for building an application. You configure whatever you need out of the build process in said file and run it. As you can see, anything you might want to do can be done this way...
 
  • #8
Jocko Homo said:
I'm curious to know specifically what you found "inefficient" about the command line...

Well so far all I've done is run a program from it, which was inefficient as I could have just clicked three times rather than writing the whole path out in the prompt. I have no doubt it's very powerful, it's just way over my head right now as I have no clue about what you guys are talking about when you mention what you do with the prompt...

I like Serena said:
The problem will be that you did not install the Eclipse CDT (C/C++ Development Tooling) plugin, which you need to develop in C++.

I was getting this error in Code Blocks, but it came with the MinGW setup which I never installed. Anyway now that I have it installed I'm still getting the same error and I am just beyond frustrated as it isn't finding the compiler automatically like it says it should online and I have no clue what the path is. I've tried C:\Program Files (x86)\CodeBlocks\MinGW\mingw32, but it's still not working. The IDE settings even lists a bunch of programs that should be in the bin subdirectory of the correct path and they are all there.

I want to use Eclipse for C++ but if I can barely handle this I doubt I can figure that out. If I can't figure this out then I'll give that a shot though since the link you gave has a step by step walkthrough.edit: Ok It's C:\Program Files (x86)\CodeBlocks\MinGW. It seems to be working now.

Thanks
m0bius
 
Last edited:

1. What is the Windows command prompt?

The Windows command prompt is a text-based interface that allows users to interact with their computer using commands and scripts. It can be accessed by typing "cmd" into the search bar or by pressing the Windows key + R and typing "cmd" into the run box.

2. How do I use the Windows command prompt?

To use the Windows command prompt, you simply need to type in your desired command or script and press enter. You can also use the "cd" command to navigate through your computer's file system and the "dir" command to view the contents of a specific directory.

3. What are some common commands used in the Windows command prompt?

Some common commands used in the Windows command prompt include "cd" for changing directories, "dir" for listing the contents of a directory, "mkdir" for creating a new directory, and "copy" for copying files from one location to another.

4. Can I customize the appearance of the Windows command prompt?

Yes, you can customize the appearance of the Windows command prompt by right-clicking on the title bar and selecting "Properties." From here, you can change the font, color, and layout of the command prompt window.

5. What are some useful tips for using the Windows command prompt?

Some useful tips for using the Windows command prompt include using the "tab" key for auto-completion of commands and file names, using the "up" and "down" arrow keys to access previously used commands, and using the "help" command to get a list of available commands and their functions.

Similar threads

  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
1
Views
660
  • Programming and Computer Science
Replies
25
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
1
Views
494
  • Programming and Computer Science
Replies
12
Views
9K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
20
Views
508
  • Programming and Computer Science
Replies
2
Views
366
  • Programming and Computer Science
Replies
29
Views
2K
Back
Top