Category Archives: C Programming

MySQL C API programming – First example

Install the MySQL C development libraries

C program

Compile the code

If everything goes well, you can see the output like this:

 

Linux C Command-line Arguments: argc & argv

When main is called in Linux C, it is called with two arguments:
1. argc(argument count): the number of arguments
2. argv(argument vector): a pointer to an array of character strings

Here is a linux shell command “echo”

The output will be:

argc: 3
argv[0]: echo
argv[1]: Rock,
argv[2]: Roll
argv[argc]: 0

Here is a C example to see more clearly about argc and argv:

Then Test the codes:

 

Precedence and Associativity of Operators

Operators Associativity
() [] -> . left to right
! ~ ++ — + – *(type) sizeof right to left
* / % left to right
+ – left to right
 << >> left to right
< <= > >= left to right
== != left to right
& left to right
^ left to right
| left to right
&& left to right
|| left to right
?: right to left
= += -= *= /= %= &= ^= |= <<= >>= right to left
, left to right

Examples

i < limit – 1

i < lim-1 && (c=getchar()) != ‘\n’ && c != EOF