Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   newbie help (http://www.go4expert.com/forums/newbie-help-t9436/)

themindroom 18Mar2008 19:57

newbie help
 
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

asadullah.ansari 19Mar2008 13:50

Re: newbie help
 
First search on net or read some books. You can easily get this sort of ?

themindroom 19Mar2008 21:28

Re: newbie help
 
Quote:

Originally Posted by asadullah.ansari
First search on net or read some books. You can easily get this sort of ?

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

asadullah.ansari 20Mar2008 10:24

Re: newbie help
 
Quote:

Originally Posted by themindroom
thank u , could not find the required. thanks anyway :cryin:

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: cpp

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?

asadullah.ansari 20Mar2008 10:32

Re: newbie help
 
Realted to conversion function you can see detail on this link

http://publib.boulder.ibm.com/infoce...c15cplr385.htm

themindroom 22Mar2008 21:50

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

Quote:

Originally Posted by asadullah.ansari
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: cpp

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?


macchiato 23Mar2008 20:24

Re: newbie help
 
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)

lead.smart34 25Mar2008 15:21

Re: newbie help
 
Quote:

Originally Posted by macchiato
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)

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

macchiato 26Mar2008 17:54

Re: newbie help
 
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...


All times are GMT +5.5. The time now is 07:54.