Is there a c/c++ version of Flash's Autofunction?

Narnia

Prince
Joined
Nov 19, 2009
Messages
513
On the code editor of Flash CS4 there is a feature called Auto format. What it does is you type in your code and it will automatically put in new lines and spaces you may have missed. It doesn't change the way the code operates, it is just a cosmetic change, making the code easier for a human to read and make sense of. Does anyone know of a similar program that works with C/C++ ? Thanks.

PS: I meant C and or C++ If there is a computer language that is actully called C/C++? I wasn't referring to it :lol:

Edit: I just realized that MS Visual C++ will automaticly insert spaces and indent for u, but it doesn't appear to also do new lines like the Flash version did. Is there something I can use to insert new lines as well? Thanks
 
Not really. Just use the format option in visual C++ (you can reformat from one of the menus, I think it is edit->advanced->format selection), and then add newlines to taste.
 
Edit: I just realized that MS Visual C++ will automaticly insert spaces and indent for u, but it doesn't appear to also do new lines like the Flash version did. Is there something I can use to insert new lines as well? Thanks

If you have one of the full versions of Visual Studio (not express) try the Visual Assist X plugin, it may support what you're looking for. But VAX is payware, you only get something like 30 days for free.

The main reason you don't see this in C++ IDE's is because the language ignores whitespace, and use of it is mostly personal preference. Some people absolutely love:

Code:
if (foo()) bar();

Others prefer:

Code:
if (foo())
  bar();

Still others prefer:
Code:
if (foo())
{
  bar();
}

But they all do the same thing.

PS: I meant C and or C++ If there is a computer language that is actully called C/C++? I wasn't referring to it

No. There's C, and C++. C++ originated from C and they share many features, but today they're two totally separate languages.
 
Code::Blocks has a plugin that will reformat code to a given style, but really, I only use it when I import someone else's code and it looks like a horrible un-indented, un-whitespaced mess. After a while, your own code just starts coming out properly spaced (for the most part) and so much so that you dont really need a code beautifier.
 
Code::Blocks has a plugin that will reformat code to a given style, but really, I only use it when I import someone else's code and it looks like a horrible un-indented, un-whitespaced mess. After a while, your own code just starts coming out properly spaced (for the most part) and so much so that you dont really need a code beautifier.

That's exactly the case here. I imported someone else's code so that I could study it and learn from it. I've simply been looking at the code and figuring out how it works. However because this particular example was an attempt to write the world's smallest decryption algorithm that could crack a particular code, the author decided to insert NO line breaks or unnecessary spaces so it is really hard to read. When I write something, it has plenty of nice line breaks and plenty of comments explaining how everything works.
 
Just use dev studio then (Edit->Advanced->Format Selection).

And put line breaks where you like them (I put them before a line which is going to open a curly brace). And add comments as you go along.
 
Back
Top Bottom