1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

newbie help

Discussion in 'C' started by themindroom, Mar 18, 2008.

  1. themindroom

    themindroom New Member

    can anyone help

    when should i make a function inline and what are the advantages of inline functions

    usefulness of pointers over arrays, file pointers and conversion function

    thanks
     
  2. asadullah.ansari

    asadullah.ansari TechCake

    First search on net or read some books. You can easily get this sort of ?
     
  3. themindroom

    themindroom New Member

    thank u , could not find the required. thanks anyway :cryin:
     
  4. asadullah.ansari

    asadullah.ansari TechCake

    When should use Inline Function: If your function has less instruction (means less statements) i.e. you can understand when function is very small, then make that function as inline.

    Advantages Of Inline Function: : First you have to understand normal function call senario. If any function call then a stack frame is created in which some context is saving like function arguments, return address etc. Actually this is overhead in a normal function call.
    In case of Inline function called, No stack frame is created. So this overhead we can save, but only for small function.
    NOTE: One thing more when we are wrinting inline function, menas we are requesting to compiler, Now comppiler see If Instructions under function
    is less then complier treats as a inline else normal function call.

    Advantages of pointer over Array: : Pointer can be incremented or decremented but in case of array, you cannt change base address of any array so you cant do such incremented or decremented operation on array to move one place to other. ( You can get anywhere more advantages)


    FILE POINTERS: : File pointer has very important role to read and write into secondary device(I/O) i.e. into files. By file pointer. By file pointer you can reach anywhere in the file any place means easily search, edit, delete etc.
    You can do this by indirection but multiple file reading writing you can'nt do . SO accessing multiple files, file pointer can handle.


    CONVERSION FUNCTION: : This concept is mainly come into c++
    Code:
    
    
    class temp
    {
    public:
        temp();
        operator float() { return f; }
    private:
        float f;
    };
    
    int main()
    {
      temp tObj;
      float f1= tObj;     // temp type is converted to float type
                          //due to we provide  a member function
                          // operator float() function which retun
                          // a float value.
    }
    

    If any doubts just straightforward ask?
     
    Last edited: Mar 20, 2008
  5. asadullah.ansari

    asadullah.ansari TechCake

  6. themindroom

    themindroom New Member

    hi, many thanks ansari JI . really appreciate your help. i am appearing for my board exams and these answers really help. thanks again :pleased:

     
  7. macchiato

    macchiato New Member

    Hi guys. . I'm a newbie /maybe dummy :)/
    teacher gave me homework.. but I can"n solve it.. Can sum1 help me??

    Write a C program that will input a 9-digit Credit Card Number, and will check whether iit is valid or not (i.e. to examine if the last 2 digits of the Credit Card Number can be generated from the first 7-digit number)
     
  8. lead.smart34

    lead.smart34 New Member

    please start a new thread this is not the right place to ask a question
     
  9. macchiato

    macchiato New Member

    Lyk what?

    Let's assume I'll do it.. Could I get any help?? İf urs answer is yea.. OK.. I'll do it..
    Thanks...
     

Share This Page