• C Programming Language Tips

    One instruction per line

    This tip submitted by Ludovic Flender on 2011-06-20 12:20:50. It has been viewed 5695 times. 
    Rating of 6.6 with 15 votes



    Use only one instruction on each line. 
    It will increase readability AND allow you to debug much more efficiently, since you will be able to watch the result of each function call separatly and directly. 

    Instead of: 
    {
        const bool result = function1(function2(function3()));
    }
    


    Prefer: 
    {
        const int res1 = function3();
        const Type res2 = function2(res1);
        const bool result = function1(res2);
    }
    


    Note the use of const correctness to make it clear that the variables are never modified. This makes it clear that you won't change these variables between the call to the function and their use as a function parameter. 

    merqery in c

    This tip submitted by jeevan on 2013-03-27 13:54:33. It has been viewed 2909 times. 
    Rating of 8.3 with 8 votes



    #include
    #include
    void main()
    {
    int i;
    char name;
    clrscr();
    printf(\"enter the name\");
    scanf(\"%s\",name);
    for(i=0;i<100;i++)
    {
    printf(\"%s\",name);
    delay(200);
    clrscr();
    }
    getch();
  • You might also like

Comment Section

Popular Posts

Leave a Message