?
Solved

Correct Formatting of C Source Code ?

Posted on 2004-11-29
10
Medium Priority
?
212 Views
Last Modified: 2010-04-15
I have created a program in C, the source code however is quite messy.

Are there any tutorials I can follow, that will show me the correct way to format my code, or even better a program that does it automatically?
0
Comment
Question by:andyw27
10 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 12694241
if you are using unix, then maybe you can try the "cb" command

$> cb yourprogram.c > newprogram.c

now newprogram.c has the better formatted code
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12694253
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12694256
0
Firewall Management 201 with Professor Wool

In this whiteboard video, Professor Wool highlights the challenges, benefits and trade-offs of utilizing zero-touch automation for security policy change management. Watch and Learn!

 
LVL 33

Expert Comment

by:hongjun
ID: 12694260
or if you have got Visual C++ 6.0, you can open your C file and then after you have selected all text, you can try Atl-F8 to auto indent
0
 
LVL 8

Expert Comment

by:rk_radhakrishna
ID: 12694384
The C programming language was developed at Bell Labs during the early 1970's. Quite unpredictably it derived from a computer language named B and from an earlier language BCPL. Initially designed as a system programming language under UNIX it expanded to have wide usage on many different systems


some of the links are:
------------------------
http://cplus.about.com/od/beginnerctutorial/l/aa010702a.htm
http://www.gustavo.net/programming/c__tutorials.shtml
http://www.eskimo.com/~scs/cclass/notes/top.html

Editors:
------------
http://www.programming-x.com/programming/syntax-highlighting.html
0
 
LVL 11

Accepted Solution

by:
dimitry earned 750 total points
ID: 12697020
For code beautify I like Astyle:
http://sourceforge.net/projects/astyle/
0
 
LVL 2

Expert Comment

by:prakashagr
ID: 12705647
> show me the correct way to format my code

download the file u will get some standards in coding

http://voxel.dl.sourceforge.net/sourceforge/astyle/astyle_1.15.3.zip

Prakash
0
 
LVL 1

Expert Comment

by:kopos
ID: 12713225
Andy,

If by formatting the code, you mean indenting it, try the utility 'indent <source_file_name>' in Linux.

but the best method is always to indent the program yourself and  follow some standards.
0
 
LVL 20

Expert Comment

by:ikework
ID: 12720551
indent on linux, makes all kinds of source-code formatting in your source-files for you

hope it helps :)
ike
0
 
LVL 20

Expert Comment

by:ikework
ID: 12720564
oops, its already been in your task, sorry ;)
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
There's never been a better time to become a computer scientist. Employment growth in the field is expected to reach 22% overall by 2020, and if you want to get in on the action, it’s a good idea to think about at least minoring in computer science …
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question