Bechitra Bechitra - 3 months ago 16
C Question

Okay with newline before semi-colon?

I'm new to C programming. I write a Basic C code
like

#include<stdio.h>
main()
{
int t =
5
;
printf("%d\n",t
);
}


Is it going to produce a error?

Well, my questing is like

int x = 9;


and

int x = //Finish this instruction in 3 lines instead of one!
9
;


Both are correct? Can i end a instruction in by using multiple line

Answer

Re-written answer after question has been clarified.

Yes, the position of the semi-colon doesn't matter. Whitespace (space, newline, tab) generally don't matter in C. It's not a line-oriented language, where source code must be rigidly structured into lines. There are lines, but they're not very important. Almost always, a newline can be changed into a space (or even removed) without changing the meaning of the code.

These are all equivalent:

int x = 1;

int y=1;

int z=1          ;

int
w
=
1
;

You should check out some Obfuscated C entries for how this can be used to creative effect.