newbie help

themindroom's Avatar, Join Date: Mar 2008
Newbie 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
0
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
First search on net or read some books. You can easily get this sort of ?
0
themindroom's Avatar, Join Date: Mar 2008
Newbie Member
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
0
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
Quote:
Originally Posted by themindroom
thank u , could not find the required. thanks anyway
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?

Last edited by asadullah.ansari; 20Mar2008 at 10:31.. Reason: Text formatting
0
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
Realted to conversion function you can see detail on this link

http://publib.boulder.ibm.com/infoce...c15cplr385.htm
0
themindroom's Avatar, Join Date: Mar 2008
Newbie Member
hi, many thanks ansari JI . really appreciate your help. i am appearing for my board exams and these answers really help. thanks again

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?
0
macchiato's Avatar
Newbie 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)
0
lead.smart34's Avatar, Join Date: Feb 2008
Contributor
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
0
macchiato's Avatar
Newbie 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...