guys ..... instead of using actual pointer arguments i have used parameters ...
this will give you a far better idea of using pointers ........and i have used setbuf function because i am using emacs , it buffers output !!...... just enjoy
#include<stdio.h>
#include<string.h>
void main()
{
char ch,str[25],del[25];
char *p,*q,*r;
int i;
setbuf(stdout,NULL);
printf("\nenter the string:-\n");
gets(str);
setbuf(stdout,NULL);
printf("\nenter the character:-\n");
gets(&ch);
p=str;
r=del;
q=&ch;
delete(p,q,r);
printf("\nthe string with the deleted characters is:-\n%s",del);
}
delete(char *p,char *q,char *r)
{
while(*p!='\0')
{
if(*p!=*q)
{
*r=*p;
r++;
p++;
}
else
{
p++;
continue;
}
}
*r='\0';
}
scanf() is an input function which reads input from the standard input devices such as keyboard. Syntax: scanf("Control Character",address_list); where control character is a sequence of one or more character such as %d,%f,%lf,%lld. Address list specifies the variables, pointers etc. e.g. scanf("%d",&num);
Yes. Examples can be found in stdio.h
Function Pointers are basically used when we want to select a function which is to be used dynamically at run time.AnswerFunction pointers are the only way for "Interept programming". In UNIX all the Interepts are called using function pointers. This is mainly used in system programming. Answerits nothing but a pointer to function. which is similar to ptr to a variable, if we are saying ptr to a variable then it will hold address of the variable like that fn. ptr will have the address of the function.. one of the major application of the function pointer is call back function.. i.e callback.AnswerPointers to functions/methods/subroutines aka 'Delegates' are frequently used in .NET programming especially in EventHandling, MemberInvoking A function pointer is used to pass a function as an argument to another function, or to store a function as a data item, for example a list of functions can be implemented as an array of pointers to functions. Function pointers are used to store interrupt handlers in tables.
No. But avoiding unnecessary duplication of data does.
// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);
Because you can produce fast and efficient code. Function arguments are passed "by value", and so you can't change the original value of the argument, but if you use pointers, you can.
Because you can produce fast and efficient code. Function arguments are passed "by value", and so you can't change the original value of the argument, but if you use pointers, you can.
A virtual function table is a table of pointers to functions.
scanf() is an input function which reads input from the standard input devices such as keyboard. Syntax: scanf("Control Character",address_list); where control character is a sequence of one or more character such as %d,%f,%lf,%lld. Address list specifies the variables, pointers etc. e.g. scanf("%d",&num);
Just as pointers can point to variables, pointers can also point to functions. Thus you can pass function pointers to functions. In so doing, you can alter the behaviour of the function by having it call dynamically call arbitrary functions rather than just preset functions.
Yes. Examples can be found in stdio.h
Function Pointers are basically used when we want to select a function which is to be used dynamically at run time.
Function Pointers are basically used when we want to select a function which is to be used dynamically at run time.AnswerFunction pointers are the only way for "Interept programming". In UNIX all the Interepts are called using function pointers. This is mainly used in system programming. Answerits nothing but a pointer to function. which is similar to ptr to a variable, if we are saying ptr to a variable then it will hold address of the variable like that fn. ptr will have the address of the function.. one of the major application of the function pointer is call back function.. i.e callback.AnswerPointers to functions/methods/subroutines aka 'Delegates' are frequently used in .NET programming especially in EventHandling, MemberInvoking A function pointer is used to pass a function as an argument to another function, or to store a function as a data item, for example a list of functions can be implemented as an array of pointers to functions. Function pointers are used to store interrupt handlers in tables.
i don't know ask someone else
function-these are self contained block of statements to solve a particular task whereas pointers are defined as the variable which stores the address of another variable
No. But avoiding unnecessary duplication of data does.
No.