I'm working as a TA in an introductory programming class, and the students tend to submit their programs as either one line, or without any indentation. Is there any tool that allows me to insert indents and things like that automatically? (We're using C++ and VisualStudio)
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
相关文章
- How to show location of errors, references to memb
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- How to track MongoDB requests from a console appli
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
Rather than answering your question I will advise:
Making their code readable for human beings is a part of programming, and you are fully justified in grading them on it. You might want to point them at the pretty printers listed in the other answers, however. Just to be nice.
There is a gnu program called
indent
, usually shipped with linux but also available here (gnu indent) and available under Cygwin.However, you are using VS, so you could use it to format code. They have hidden the feature just a bit:
Edit -> Advanced -> Format Document
, or Control/E, D.In Vim it's
gg=G
.Select the entire file (Ctrl-A) and then hit Ctrl-K Ctrl-F, which is essentially format the entire document.
EDIT: Of course in Visual Studio IDE
If you need to do this in batch mode, try using astyle, also available in the Cygwin installer.
You're after a pretty printer. I'd suggest Googling for C++ pretty printer, and looking for something that meets your requirements (price, platform).
As an aside, you may find that deducting marks for poorly formatted code will work just as well. Students need to learn that good code layout is an important part of writing maintainable code.