Which command is more efficient?
*(ptr+1) or ptr[1]

Answer Posted / poornima

If ptr is declared as a pointer like int *ptr; *(ptr+1) is
more efficient.
If ptr is declared as an array like int ptr[20]; ptr[1] is
more efficient.
So, it depends upon how we r declaring ptr as a pointer or
as an array.

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are terms in math?

600


Which is the best website to learn c programming?

591


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

734


write a c program to find the sum of five entered numbers using an array named number

1626


What is the use of bit field?

654






Why doesn't C support function overloading?

1632


main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }

928


Explain the red-black trees?

615


Write a C program in Fibonacci series.

645


FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.

1210


How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?

1599


What is a dynamic array in c?

604


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

595


What is the maximum no. of arguments that can be given in a command line in C.?

677


Why c is called procedure oriented language?

589