Pretty Code

Have you ever gotten a piece of code that looks like this:

  void main(){int a= 0;for(int i = a+1
       ;i <99;i++)
   {int j = 8 + i;cout<<a<<' '
  <<i<< ' '<<' '<<j;}}

When it could be written like this:

void main( )
{
    int a = 0;
    for ( int i = a + 1; i < 99; i++ )
    {
         int j = 8 + i;
         cout << a << ' ' << i << ' ' << j;
    }
}

Is there a FREE or cheap helper application out there that can transform the first exmaple into second example?

Please don't just list some URL.  Please state the title of the application and the name of the company that produces it along with your URL.
LVL 1
ElmerFudAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ElmerFudAuthor Commented:
Edited text of question.
0
chensuCommented:
The Visual C++ editor is able to do it.
0
ElmerFudAuthor Commented:
how?
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

ElmerFudAuthor Commented:
I'm using Visual C++ 5.0
0
ElmerFudAuthor Commented:
I'm using Visual C++ 5.0
0
ElmerFudAuthor Commented:
I found some info on it in the help file.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

How Can I Pretty-Print My Code?

You can select sections of code to automatically indent (AutoIndent), but the Text editor does not automatically reformat to merge or break up lines of code.

To quickly indent sections of code, first set the Smart Indent settings you want (choose Options from the Tools menu, click the Tabs tab, then change the Smart Indent options). Then select the code you want to format, choose Advanced from the Edit menu, and then choose Format Selection.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

I tried this but it did not output what I had expected.  Is there some other way to do it in Visual C++?
0
PeteICommented:
See Visual SourceFormat from RGI Software, available at http://www.ralgi.com/products/vsf/vsourceformat.html

It includes a version you can download for free to try it out.  It apparently also integrates with MS Visual Studio.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
s_franklinCommented:
Your best bet is "indent", a freely available tool from GNU software. C++ is not fully supported, but I have yet to run into any major problems with indent. You can get a dos-compiled binary from:

http://burks.bton.ac.uk/burks/software/devtools/index.htm

Also, I have to suggest NT Emacs even though I risk abuse :) You can read about it at the following FAQ (yes it does reformat as well as do smart-indenting/formatting during text entry):

http://www.gnu.org/software/emacs/windows/ntemacs.html

SlickEdit is a commercial editor that supposedly does a nice job of batch reformatting:

http://www.slickedit.com/
http://www.softpanorama.org/Editors/edit_win32.shtml#SlickEdit

Finally, there is a good summary of some alternative tools at:

http://www.greymatter.co.uk/gmWEB/nodes/NODE0689.HTM

Steve
0
ElmerFudAuthor Commented:
Exactly the type of thing I was looking for a bit expensive, $99, but I can live with it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.