fight between me and c

Upload: swati-bhatia

Post on 07-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Fight Between Me and C

    1/14

    Small fightBetween me and C

  • 8/3/2019 Fight Between Me and C

    2/14

    #include #include int main (){int i = 20; ; ; ; // no matter how many semicolons printf ( "%d" , i );getch();}

    Rohit:Semicolon!!!! is completely waste thing

  • 8/3/2019 Fight Between Me and C

    3/14

    #include ;;;#include int main (){;;; int i = 20;printf ( "%d" , i );getch();} ;;;

    Rohit:Semicolon!!!! is really of no use

    Semicolon: dont call me like thisI am statement terminatorRohit:yeah, I understandSo, in the above program,you are terminating the main

  • 8/3/2019 Fight Between Me and C

    4/14

    int fun ( int i ) {

    printf ( "%d", i );}int main (){fun ( 2 );}

    I am parameterNo, I am argumentNo way, I am parameter.

    Ok we are bros.Nooooo, go away dont call mebroI am parameter

    Rohit:Again stupid fightyes, i is parameter and 2 is argument

  • 8/3/2019 Fight Between Me and C

    5/14

    int main () {int i = 100, j = 200;printf ( "%d %d" );

    getch ();}Guess the output:a) garbage garbageb) 200 100

    Rohit:Both a and b are righta in Devb in TC

  • 8/3/2019 Fight Between Me and C

    6/14

    Array: I provide you so many optionsto simplify programming like: arr[2] or 2[arr]Rohit: ohh but why arr[-2] != -2[arr]

    Macro: You can declare me any where in ur programint main (){#include printf ( "Hello" );getch ();}Rohit: okk..so, TC is ur personal friendbcz above code never worked with DEV !!!

  • 8/3/2019 Fight Between Me and C

    7/14

    int main (){

    int i=10;int j = 20;int *p;p = &i;*p++ = j; // no error++*p = j; // error getch ();

    }

  • 8/3/2019 Fight Between Me and C

    8/14

    int main (){void *v;int i=10;int *j;v=&i;

    i=*(int*)v; // should castj = v; // no needgetch ();}

    Void *: Hi, I am void *, my nick name is void pointer,I provide you many facilities for generic programmingBut you should typecast me before u useRohit: Okk, I agree with you

    but why you apply this rule for general variablesnot to pointersok I got it you have BHAICHARAwith pointers

  • 8/3/2019 Fight Between Me and C

    9/14

    UDV: I provide you the facility of creating your own typeslike: struct, union, enumRohit: But why you do the partiality with in your familystruct and enum can be blanks, but enum cant

    struct a {};

    union b {};enum c { //error};int main (){getch ();}

  • 8/3/2019 Fight Between Me and C

    10/14

    typedef: I allow programmersto change name of types,which simplify programming!

    typedef char * a;const a b; => b is constantconst char * b => *b is constant

    Rohit: simplify in whatsense. It actually makedifficult

  • 8/3/2019 Fight Between Me and C

    11/14

    main(): I am main(), I am starting point of your programRohit: Welcome, I was desperately waiting for youeveryone, please look at the main(),main(): Oh, please dont stare me

    Rohit: no, no I was just thinking.. If you are the startingpoint, what about pragma startup and end ;)main(): no, but I care for them I am the actual functionand I also allow you to have argumentsRohit: ok and you are not sure yourself,

    how many arguments?main(): They are always three arguments..Rohit: But I did never use 3 argumentsmain(): But you shouldRohit: But why your arguments are modifiable?

  • 8/3/2019 Fight Between Me and C

    12/14

    sizeof(): Hi,I allow you to know size of any variable/datatypeRohit: Seriously, I am fed up of you, you better move outsizeof(): infact, I am really helpfulRohit: I said move out, otherwise.Achcha nhn hoga

    sizeof(): what otherwise what can you doRohit: I will show all your statements to publicsizeof(): ok, lets see I was always right, you are wrong..Rohit: ok.. Lets see what others have to say:Hello, every one I will show you some statements,

    you have to tell.. Whether sizeof() is fair or unfairwith everyone

  • 8/3/2019 Fight Between Me and C

    13/14

    sizeof ( NULL ) => 4sizeof ( 'A' ) => 4 ( in C )sizeof ( 'A' ) => 1 ( in C++ )char ch;sizeof ( ch ) => 1sizeof ( near ) => 2 ( in TC )

    sizeof ( near ) => error ( in GCC )int *b[3][4];sizeof (b) => 48sizeof (*b) => 16sizeof (**b) => 4int (*b)[3][4];sizeof (b) => 4

    sizeof (*b) => 48sizeof (**b) => 16char *s;sizeof ( s ) => 4sizeof ( *s ) => 1

  • 8/3/2019 Fight Between Me and C

    14/14

    Thank YouRohit [email protected]://go.to/RohitBirlaSoftwaresAll the contents are taken from internet, or from various books. However all the content is tested, butstill author takes no responsibility for the content. Information here is being presented just for yourreference. This presentation is free of cost, you can use it and distribute it, however you cant charge forit except for distribution charges.