Skip to content

vivekimsit/practice-c

Repository files navigation

practice-c

Join the chat at https://gitter.im/practice-c/general

Revising C lang

The codes here are just for learning purpose, there may be better ways to write them.

TODO

  • Types, Operators and Expressions
    • Data types and sizes
    • Enum data type
    • Type conversions
    • Constants
    • Operators (Assignment, bit and ternary)
    • Increment and decrement
    • Precedence
  • Flow Control
    • if/else
    • switch
    • while
    • do-while
    • for
    • Examples
  • Functions
    • Examples
  • Recursion
  • Pointers
    • Introduction
    • Functions
    • Arrays
    • Pointer arithmentic
    • Character ararys
    • Array of pointers and multidimensional arrays
    • Pointer to functions
    • Examples
  • Arrays
  • Strings
    • Basic operations on string
    • Examples
      • Compare
      • Concat
      • Copy
      • Count
      • itoa
      • atoi
  • Storage Classes
    • Register
    • Static
    • Global
  • Structures and Unions
    • Malloc
      • Process memory model
  • Input/Output
  • File Input/Output

Pointers to functions

int *fp(int, int);

its not the pointer to the function because
() has higher precedence to * hence its interpreted
as fp as function which returns a pointer to an int.

int sum(int, int);
     |
int (*fp)(int, int);

since, () is left associative hence above
is pointer to a function which takes two 
ints and returns an int.


fp = sum
s = sum(5, 6)
s = (*fp)(5, 6)

The () is left associative hence

Malloc

void* malloc(int);

example:

Allocate a memory block of 10 and return the address.

int *p = (int*) malloc(10);

But size of int is platform dependant, hence:

int *p = (int*) malloc(5 * size(int));

About

One bit at a time (Routine is the key)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages