Jump to content

which one is right (How to type)

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
I want to make simple tutorial in C++
Now I want to know which one these code is right?
int a = 20, b = 3;
a = 2 * (b = 8);


or
int a=20,b=3;
a=2*(b=8);

also give me an example to find others!

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
You would likely wish to add spacing inbetween such tokens (a, =, etc.). Neglecting proper spacing to distinguish specific tokens can lead to readability issues, you may wish to look at some of the common indent styles here:

see: Indent style - Wikipedia, the free encyclopedia

This is but one of many resources on proper spacing.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
fayyazlodhi

fayyazlodhi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 403 posts
From Google coding conventions the section on formatting
http://google-styleg...ls#Conditionals

It is worth nothing that these styles are given enough importance to be included as part of coding conventions followed by every decent professional software development organization.
Today is the first day of the rest of my life

#4
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
Is there any program that do this job for me?

#5
fayyazlodhi

fayyazlodhi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 403 posts
Depending upon what platform and editors you are using this can be done.

This is one utility for Unix / Linux. The link also mentions a few others.
indent (Unix) - Wikipedia, the free encyclopedia

Also you can easily find scripts for vim editor doing default settings for code.

For windows, mostly there are short cuts for these settings for e.g. in Visual studio you can set tab space in editor setting.

Then you can "select all" a file and pressing CTRL+K+F would format the whole code whatever state it was in according to current settings.

Edited by fayyazlodhi, 21 July 2011 - 02:37 AM.
typo

Today is the first day of the rest of my life




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users