PDA

View Full Version : brackets in C programming



Stoddard
2011-12-01, 11:00 PM
How many different brackets are there in C programming, other than round and curly? And what is the main difference between round and curly brackets, anyhow?

suwunk
2011-12-02, 01:39 AM
( ) round brackets (parentheses) = for function declarations/definitions/calls
{ } curly brackets (braces) = to group sections of code
< > angle brackets for header files = for header files
[ ] square brackets = for arrays

evantanski
2012-01-27, 01:12 AM
[] for arrays
{} to group sections of code (like after an if statement)

evantanski
2012-01-27, 01:14 AM
You can apply code with brackets in c.

#include <stdio.h>

int main ( void )
{
struct
{
char c[15];
int x;
} table [ ] =
{
{ "Hello.", 1 },
{ "Do you", 22 },
{ "understand", 333 },
{ "all this", 4444 },
{ "yet?", 55555 },
};
int x;

for(x = 0; x <5; x++ )
{
printf( "%s\t%d\n", table[x].c, table[x].x );
}

printf( "< > and << >> are omitted because I'm tired of typing all this bold crap.\n" );

return 0;

Brynnae
2012-04-06, 04:25 AM
BODMAS is the rule used in C for opening a brackets.

First Brackets will be Open then Of will be executed then Division will be performed then after Multiplication, Addition and Subtraction will be executed.