Have a look at emacswiki – autoindent
As suggested there, put following code in your .emacs
(defun set-newline-and-indent () (local-set-key (kbd "RET") 'newline-and-indent)) (add-hook 'c-mode-hook 'set-newline-and-indent)
You can customize the variable C Default Styl. In your emacs go to Options->Customize Emacs->Specific Option, then type c-default-style and set to your choice. By doing this, you don’t need to hit TAB. Type from start of the line and as you hit “;” , it will be automatically indented.
Hope this helps