OnWorks favicon

bcpp - Online in the Cloud

Run bcpp in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command bcpp that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator



bcpp - make C++ beautifier


bcpp [-bcl] [-bnl] [-cc <num>] [-f <num>]
[-fi <input file name>] [-fnc <custom config file>] [-fo <output file name>] [-h] [-i
<num>] [-lg] [-nc] [-qb] [-s] [-t] [-tbcl] [-tbnl] [<other options>] [<input file name>]
[<output file name>]


-bcl Open braces on code line

-bnl Open braces on new line

-cc <num>
Column to align comments with code

-f <num>
Function line spacing

-fi <string>
Input file name

-fnc <string>
Load custom configuration file

-fo <string>
Output file name

-h, -? Display help message

-i <num>
Indent space length

-lg Leave graphic chars

-nc <num>
Column to align comments with no code

-qb <num>
Define internal queue buffer size

-s Use spaces in indenting

-t Use tabs in indenting

-tbcl Top-level open braces on code line

-tbnl Top-level open braces on new line


Options beginning with -y or -n enable/disable functions, respectively.

-ya or -na
Open braces on code line

-yb or -nb
Backup input file with .bac extension

-ybbi or -nbbi
Indent both braces of a block

-ybi or -nbi
Indent trailing brace of block

-ykcwc or -nkcwc
Keep comments with Code

-ylcnc or -nlcnc
Leave comments with NoCode

-yo or -no
Program output

-yq or -nq
Change non-ASCII chars in quotes to octal


This program enables a user to reformat certain elements of a C, or C++ source code. This
helps if one person's code is a little unreadable, or has been indented to a style that
you dislike. Using this program will hopefully help in re-styling the code so that it
closely meets your style. However, due to the many styles of C(++) that can be coded,
there are limits to how well this program will handle the source code, and resulting re-
formatted source.

The following are a list of features implemented:

- Reposition comments at certain locations.

- Remove non-printable characters not contained within quotes.

- Convert non-printable characters within quotes to octal/character notation.

- Re-space line spacing between functions.

- Trim trailing spaces from all lines, as well as leading and trailing blank lines
from the file.

- Reposition opening braces to Kernighan/Ritchie style, or to Pascal style.

- Use of tabs, or spaces in indenting.

- Indention of single line code, according to certain C condition statements,
including embedded SQL statements.


This program will run under Microsoft DOS V3.3 and Unix platforms.

It uses approximately 50 - 70k (or more, dependant upon internal queue size) of memory
during execution.

The program code has been written in such a way as to be compatible with existing C++
compilers, however the code is not ANSI standard and may require modification for your
environment. The source code has been written with standard ANSI and Posix functions so
that least amount of rewriting should be needed if recompiling on another computer

The current sources have been compiled using Turbo C++ V3.0, for MS-DOS, GNU G++ 2.7.2
under Sun SPARCstation running SunOS, Solaris as well as SGI workstations running IRIX.


Operation of the program is via the command line (CLI), and with help from a configuration
file you can define your format requirements. Basically each command directive starts with
a dash "-" followed my the command name. If another parameter is need for the command, the
parameter is added after the command, and separated with a space (i.e. bcpp -fi

N.B: Do not enter bcpp.exe on its own to find its command help, use bcpp -?, or bcpp -h.
This is due to the input redirection from the O/S. Keeping to Unix CLI convention, a
string that is read from the CLI and does not have a command directive is considered a
input file. If there are two such occurrences on the command line, the precedence will be
input file first, and output file second (i.e., bcpp infile.cpp outfile.cpp -lg), a third
such occurrence will generate a error message.

If no output file is presented, its assumed output is via the standard output. This
automatically turns off program output. Parameters entered on the command line will
override parameters that have been read from the configuration file.

bcpp -fi input.cpp -f 2 -qb 5 -na -no -cc 60 > output.cpp


-fi input.cpp Input file = input.cpp
-f 2 Function spacing = 2
-qb 2 Internal Queue Buffer = 5
-na Remove non-ascii chars
-no Suppress program output
-cc 60 Comments that appear on same line as
code will be placed in column 60.
> output.cpp Output of program is redirected to

A configuration file can be used to specify most of the non- changing elements in
reformatting of code. The configuration file consists of some fairly lengthy words that
are used to explain the output style of the code. However setting these parameters is very
easy, they basically consist of two types, Boolean, or Integer types. Using your favorite
text editor, you can change the following within the configuration file ...

The following parameters will be contained within the configuration file (default is
bcpp.cfg). The program will attempt to read the default configuration file at the program
source (i.e. which path bcpp was run). Using the -fnc option you can define a custom
configuration file name, and path from the CLI.

Integer Type Ranges : 0 - 5000 Boolean Type Ranges : On, Yes, or Off, No

Function_Spacing : Integer
This parameter specifies how many lines separate two functions.

function_spacing = 2

-f 2

Use_Tabs: Boolean
Specifies whether to use tabs in indenting code.

use_tabs = no

-t (Turn tabs on, default uses spaces)
-s (Use tabs for indenting)

Indent_Spacing : Integer
Specifies how many spaces to indent. This parameter also sets the width of tabs.
Bcpp considers the width of a tab to be the same as the width of an indent.

indent_spacing = 4

-i 4

Comments_With_Code : Integer
Defines the column in which comments that appear after code on a line will be

comments_with_code = 50

-cc 50

Comments_With_Nocode : Integer
Defines the column in which comments that appear in a line will be placed.

comments_with_nocode = 0

-nc 0

Indent_Preprocessor: Boolean
If true, bcpp will indent preprocessor lines to the indention of the C(++) code.
If false, preprocessor lines will be in the first column. Unrecognized (i.e.,
nonstandard) preprocessor lines are always put into the first column.

Indent_Exec_Sql: Boolean
If true, bcpp looks for embedded SQL statements (e.g., EXEC SQL), and formats
them specially.

Keep_Comments_With_Code : Boolean
This option overrides the "Comments_With_Code" option. Setting this option On
will make comments which do not fit as inline comments append to the code

Leave_Comments_NoCode : Boolean
This option overrides the "Comments_With_Nocode" option. Setting this option On
will indent comments that do not occur on the same line as code to the same
indention as code.

leave_comments_nocode = on

-nlcnc (Turn off Leave_Comments_NoCode)
-ylcnc (Turn on Leave_Comments_NoCode)

NonAscii_Quotes_To_Octal : Boolean
Use this option to change non-ASCII (non-printable) chars to octal notation if
they lie within quotes. This parameter does not take effect unless either the
Ascii_Chars_Only or Leave_Graphic_Chars parameters have been set.

NonAscii_Quotes_to_Octal = no

-nq (Turn off non-ascii chars in quotes to octal)
-yq (Turn on non-ascii chars in quotes to octal)

Leave_Graphic_Chars : Boolean
Setting this parameter to yes will strip non-printable characters from the
source file, but leave any characters that are IBM graphics alone. Any non-
printable characters that lie within quotes will be transformed into
octal/character notation, if NonAscii_Quotes_To_Octal parameter is set to True.

leave_graphic_chars = yes


Ascii_Chars_Only : Boolean
Setting this parameter to yes will strip any non-printable, non-ASCII characters
from the input file. Any non-printable characters that lie within quotes will be
transformed into octal/character notation if NonAscii_Quotes_To_Octal is set to
True. Comment out this parameter if you are using Leave_Graphic_Chars parameter,
as this parameter will override it.

ascii_chars_only = yes

-na (Do not remove non-ASCII characters)
-ya (Yes remove non-ASCII characters)

Place_Brace_On_New_Line : Boolean
When set to 'on' bcpp will place opening braces on new lines ("Pascal" style C
coding), when set to 'off' bcpp will use "K&R" style C coding.

Pascal style C coding:
if (condition)

K&R style C coding:
if (condition) {

place_brace_on_new_line = on

-bnl (on )
-bcl (off)

Program_Output : Boolean
This parameter will stop output from the program corrupting output that may exit
from the program via the standard output. If this parameter is set to off/no
then no output is generated from the program, unless an error is encountered.
The standard error is used to display any errors encountered while processing.

program_output = off

-no (default is generate output if possible, this will
force output off)
-yo (turn on program output if possible)

Queue_Buffer : Integer
Specifies what the internal memory requires will be in size of the line
processing buffer. This is used for open brace relocation in Kernighan/Ritchie
style. Extending this buffer to large amounts of memory will slow processing on
small machines.

Queue_Buffer = 2

-qb 2

; : Not Applicable
Placing a semicolon in front of text makes everything after the semicolon a

Backup_File : Boolean
This option will backup the input file to a file with the extension ".bac" and
overwrite the input file with the reformatted version.

backup_file = yes

-yb (yes, backup input file if possible)
-nb (no, do not backup input file)

Loading Configuration File : CLI only

Bcpp implements a configuration setting to allow custom file selection from a specific
path/file defined by a user.

bcpp input.cpp -yb (read bcpp.cfg configuration file
before processing CLI options)

bcpp -fnc /bin/bcpp.cfg (load configuration file at
said location)

-fnc (use user defined)

Input File Name : CLI only
This option directs bcpp to read data at a given path, and file name.

bcpp -fi input.cpp > output.cpp


Output File Name : CLI only
This defines the output file name that data is to be written to.

Has to be like this, (in DOS, at least):

bcpp -fo output.cpp < input.cpp


Online Help : CLI only
Some online help which is brief but to the point exists within the program. The
help lists all of the CLI commands available within the program.

E.G bcpp -h

CLI bcpp -?
bcpp -h

Configuration File Error Messages

If you enter a command/parameter incorrectly within the configuration file, upon the
executable program reading it, the program will generate a error message along with its
line number. The following is an explanation of error messages that may occur while
reading parameters within the configuration file.

Syntax Error After Key Word :
Error occurs because the character/word after a parameter was incorrect, or
expected another keyword (e.g =, Yes, No, On, Off)

Range Error :
Error occurs when integer parameters have a invalid numeric setting (i.e., A
number is not within 0 - 5000).

Expected Numeric Data :
This error occurs when alpha-numeric data is in place of numeric data for integer
type parameters.

Cannot Decipher :
The parameter at said line is not valid (i.e., not recognizable).

If any errors have occurred after reading the configuration file; the user is prompted
with a [y/n] continuation prompt to either fix the configuration error(s) before
processing, or continue with current set parameters.

Run Time Errors During Input File Processing

Memory Allocation Failed :
The program was unable to allocate memory to process data. This error will stop
processing of data.

Error In Line Construction

Expected Some Sort Of Code ! Data Type = ? :
This error is generated within the line construction process. The decoded line
from the input file may be too indecipherable for this program. Find the line in
the input file, and see if it can be altered so that processing can continue.

C(++) Beautifier Limitations

This section highlights certain areas within code where bcpp will fail to reconstruct the
output code to the desired style (although it may still be able to compile).

- All code that is fed through this program should be in a compilable state. This
means that there should be closing braces that cancel out opening braces. Bcpp
does no syntax checking at all upon the code, but reformats it according to open,
closing braces, and a handful of key words for single line indentation.

- There is also a limitation on how far the movement of open braces can be
processed. This is due to the current design of the program (this can fixed easily
by extending the internal queue buffer size), memory requirements, processing
speed. Dynamic memory allocation is used extensively throughout the program, and
may exceed current limits if certain conditions arise.

The example shows that the movements of the brace from the new line to the above
code line will not take place as it would be out of scope for the program if the
internal queue buffer is limited to 2 lines in size.

Example of brace movement scope:

if (a == b)
// Brace will not be re-positioned
b = c;

if (a == b) // Brace will be re-positioned
b = c;

End Result

if (a == b)
// Brace will not be re-positioned
b = c;

if (a == b){ // Brace will be re-positioned
b = c;

- There is a constraint that a single line of code should only have one type of
comment. If there are both C, and C++ existing on the same line then the line
construction phase of the program will become confused, and generate a error
message. The following line will produce a Line Construction Error message.

Example of multiple comments.

/* C Comment */ a = b; // C++ Comment

The above line will generate an error. Remedy this by removing one type of
comment, combine them, or place one on a new line.


Written By Steven De Toni December 1995
Updated by Thomas Dickey January 1997-2002

You can contact Steven De Toni via various online networks:

Internet Address
[email protected]
[email protected]

Net Mail Via Fido-Net (Dog Net)
Steven De Toni,
"The Great Escape",
New Zealand

Demi-Monde New Zealand National Mail Net Work
(see Dog Net)

If all else fails, send snail mail to:

17 Garden Heights Ave,
New Zealand

Thomas Dickey can be reached at

[email protected]

Special thanks goes out to Glyn Webster for proof reading my manual, and testing my

Thanks to Justin Slootsky for his input, and changes for this version.

All grammatical errors within this document are there for your enjoyment. ;-)


The authors give no guarantees that this program will function to the specifications given
via the configuration, or the program's reconstructed output of source code that have been
processed. Any damage that might arise from the use of this program (be it software, or
hardware) is the problem of user, and not the authors. Using this software binds you to
this disclaimer.=

C++ Beautifier()

Use bcpp online using onworks.net services

Free Servers & Workstations

Download Windows & Linux apps

  • 1
    TurkDevOps a�?k kaynak yaz?l?m
    geli?tirici topluluklar? DevTurks-Team
    Taraf?ndan desteklenmektedir..
    Download turkdevops
  • 2
    *asammdf* is a fast Python parser and
    editor for ASAM (Associtation for
    Standardisation of Automation and
    Measuring Systems) MDF / MF4
    (Measurement Data Format...
    Download asammdf
  • 3
    LAME (Lame Aint an MP3 Encoder)
    LAME (Lame Aint an MP3 Encoder)
    LAME is an educational tool to be used
    for learning about MP3 encoding. The
    goal of the LAME project is to improve
    the psycho acoustics, quality and speed
    of MP...
    Download LAME (Lame Aint an MP3 Encoder)
  • 4
    A set of Python extension modules that
    wrap the cross-platform GUI classes from
    wxWidgets.. Audience: Developers. User
    interface: X Window System (X11), Win32 ...
    Download wxPython
  • 5
    This is the Total War pack file manager
    project, starting from version 1.7. A
    short introduction into Warscape
    modding: ...
    Download packfilemanager
  • 6
    A network traffic tool for measuring
    TCP and UDP performance with metrics
    around both throughput and latency. The
    goals include maintaining an active
    iperf cod...
    Download IPerf2
  • More »

Linux commands