views:

131

answers:

5

I want to learn how can I visualize my small c programs using some type of diagrams . My programs generally include (3 or 4 functions) (some loops) (basic i/o (printf scanf)), and basic calculations. I do not want to visualize everything about my program(name of vars, type of vars) , but I want to create some type of diagram which will help other person to understand how it works .Instead of showing 150-250 lines of code I want to show 1-2 page schema.

Things I want to show (which I do not know how to show):

  • Inputs and Outputs (printf, scanf)
  • Loops
  • Control Statements

Also, I am looking for agreed and standart way of doing this .

+2  A: 

Basically, choosing the correct type of diagram would depend on what you want to show, but if you want other people to "understand how it works", I believe that a flow chart will suit your needs.

Eldad Mor
A: 

If you have access to Visual Studio 2010, certain versions come with a flurry of tools to do this, here is one of the earlier articles outlining some features.

RandomNoob
A: 

UML was all the rage a decade ago. It defines a bewildering number of diagram types, one of which is the "Activity diagram". It is a standard for drawing diagrams that show the things you want to show. See http://en.wikipedia.org/wiki/Activity_diagram for an example and links.

I would definitely prefer code or pseudo-code over a diagram though. I think most people who are used to reading code would.

A: 

You can compile the program with gcc's gprof profiling options and then convert the output of the run to a visual call graph using a tool like Gprof2Dot.

While this isn't quite the level of detail you're hoping for it's probably the best you can do. I've always found it to be a useful way of getting to know an unfamiliar code base.

Robert S. Barnes
A: 

There are many software visualization tools available. Check http://en.wikipedia.org/wiki/Software_visualization for a summary. I like Enterprise Architect from Sparx Systems. It's under $200 and is a full-featured UML tool that allows round-tripping your code and models.

Bruce