Pointers datastructures interview questions
What is a void pointer?
What is the difference between #define and constant in C?
What are the advantages of the functions?
What is a static function?
How do you override a defined macro?
What is use of macro arguments in c?
Is it better to use malloc() or calloc()?
Is it better to use malloc() or calloc()?
What is the difference between goto and longjmp() and setjmp()?
What is a static function?
When should a type cast not be used?
What is pointer?
How can you check to see whether a symbol is defined?
Write a program which accepts a filename
Difference between arrays and pointers?
What is a null pointer?
What is the difference between text and binary modes?
What is the difference between #include
Between a long pointer and a char pointer
When is a switch statement better than
What is a pointer variable?
How can I sort a linked list?
What is a function and built-in function?
How can you determine the size of an
What is the difference between a string and an array?
Why n++ executes faster than n+1?
How can type-insensitive macros be created?
What is a NULL Macro? What is the difference
What is the draw back in using friend function in c++
c is a structural or highlevel or middle level
If we develop a project in C, then how can
What are advantages and disadvantages
What is storage class and what are storage variable ?
How reliable are floating-point comparisons?
Where are the auto variables stored?
What is an argument ? differentiate between
How can you determine the maximum value
What is a pointer value and address?
How can i find size of a variable without
How can we open a image file through C program
How can I open a file so that other programs
What will the preprocessor do for a program?
How to improve my c knowledge.......
what is a modulus operator? What are
How do you print only part of a string?
Are pointers integers?
What is modular programming?
What is the difference between declaring
What is major difference between normal
What are the advantages of auto variables?
How to find a given number is Armstrong
What is a method?
What is indirection?
main() { int i = 0xff ; printf("n%d", i
How to write a program such that it will
When should a far pointer be used?
What is the stack?
What is the difference between declaring a
What is the benefit of using const for
What is a const pointer?
How do you redirect a standard stream?
Can you define which header file to
What is a pragma?
When would you use a pointer to a function?
What is the purpose of main( ) function?
Which expression always return true?
What does it mean- a[i]=i+i
Differentiate between an internal static
What is the easiest searching method to use?
How do we get Square root of any number
Can include files be nested?
What is hashing?
What is the benefit of using an enum
What is far pointer?
What is the heap?
Is using exit() the same as using return?
When should the register modifier be used?
How can send unlimited no of arguments to a
What is the quickest sorting method to use?
How to find entered number is EVEN or
Write the equivalent expression for x%8?
What is the difference between #include
How do you print an address?
Can you add pointers together? Why would you?
How can I convert a number to a string?
How many levels of pointers can you have?
Can static variables be declared in a header file?
What is a “null pointer assignment” error?
What is static memory allocation and
Is NULL always defined as 0?
What are returned by printf(), scanf() functions,
What is #line used for?
How can I convert a number to a string?
How do you determine whether to use a stream
How can you restore a redirected standard stream?
What is a null pointer?
How to write a C program to find the power
What are the standard predefined macros?
main() { signed int bit=512, mBit; { mBit = ~
When does the compiler not implicitly generate
when should the volatile modifier be used?
We should not read after a write to a file without
How to swap the content oftwo variables
When should a type cast be used?
How can you avoid including a header more than once?
Why should we assign NULL to the elements
What is the difference between a string copy
C program for delete a node from linked list
C program for delete a node from linked list
What is the purpose of main( ) function?
Can math operations be performed on a void pointer?
How will you print % character?
Can the size of operator be used to tell the size
How are pointer variables initialized?
What is page thrashing?
How can you calculate number of nodes in a circular Linked List?
Can a file other than a .h file be included with #include?
How can I search for data in a linked list?
What is the easiest sorting method to use?
When function say abc() calls another function
Is it better to use a macro or a function?
Can we use string in switch statement?
What is a const pointer?
How to break cycle in circular single link list?
What is the benefit of using const for declaring constants?
Can a variable be both const and volatile?
How do you write a C program which can
Is it possible to execute code even after the program
A switch statement cannot include a) constants as arguments
Write a code for implementation of doubly linked
What do you mean by normalization of pointers
What are the characteristics of arrays in C?
What is the difference between #include and #include" "
How can I make sure that my program is the
How to convert Stack in to Queue and varsa ?
What is the quickest searching method to use?
What is Preprocessor?
How do you write a program which produces
How do display the list in single linked
How to remove duplicate elements from an array
If compiler for c is written in c language, which
How to perform matrix multiplication using
How to type a string without using printf function?
What is the difference between far and near?
What is the difference between text and binary modes?
What is the difference between NULL and NUL?
What is the purpose of realloc( )?
When is a switch statement better than multiple if statements?
Can a variable be both const and volatile?
What is the benefit of using #define to declare a constant?
What are storage class in c
How do you use a pointer to a function?
Can the size of an array be declared at runtime?
Why do we need to test weather it is memory leak or not?
How are portions of a program disabled in demo versions?
How many levels deep can include files be nested?
How can I sort things that are too large to bring into memory?
What does it mean when a pointer is used in an if statement?
Why should I prototype a function?
What is a macro, and how do you use it?
Differentiate between a linker and linkage?
Difference between Function to pointer and pointer to function
Can static variables be declared in a header file?
Is it acceptable to declare/define a variable in a C header?
Difference between arrays and pointers?
Showing posts with label c pointers faqs. Show all posts
Showing posts with label c pointers faqs. Show all posts
what is the Difference between arrays and pointers?
What is the Difference between arrays and pointers?
- Pointers are used to manipulate data using the address. Pointers use* operator to access the data pointed to by them
- Arrays use subscripted variables to access and manipulate data.
Array variables can be equivalently written using pointer expression.
Program to show that array and pointers are different
#include
int main()
{
int arr[] = {10, 20, 30, 40, 50, 60};
int *ptr = arr;
// sizof(int) * (number of element in arr[]) is printed
printf("Size of arr[] %ld\n", sizeof(arr));
// sizeof a pointer is printed which is same for all type
// of pointers (char *, void *, etc)
printf("Size of ptr %ld", sizeof(ptr));
return 0;
}
int main()
{
int arr[] = {10, 20, 30, 40, 50, 60};
int *ptr = arr;
// sizof(int) * (number of element in arr[]) is printed
printf("Size of arr[] %ld\n", sizeof(arr));
// sizeof a pointer is printed which is same for all type
// of pointers (char *, void *, etc)
printf("Size of ptr %ld", sizeof(ptr));
return 0;
}
Output:
Size of arr[] 24
Size of ptr 8
Assigning any address to an array variable is not allowed.
Keywords:
relation between array and pointer in c
differentiate between array of pointers and pointers to array
difference between array and pointer in c in hindi
difference between array and pointer in hindi
which of arrays or pointers are faster
difference between array and structure
array vs pointer in c
difference between pointer and reference
How pointers are initialized?
How pointers are initialized?
Pointer variable are initialized by one of the following two ways- Static memory allocation
- Dynamic memory allocation
Keywords:
how to initialize a pointer c++
declaration and initialization in c
pointers in c
initialize pointer with address
declaration and initialization of pointer variable in c
pointer arithmetic in c
syntax of pointer initialization
pointer declaration in c++
c faqs on pointers
C faqs on pointers
1)What are pointers really good for, anyway?2)I'm trying to declare a pointer and allocate some space for it, but it's not working. What's wrong with this code?
char *p;
*p = malloc(10);
3)Does *p++ increment p, or what it points to?*p = malloc(10);
4)I'm trying to use pointers to manipulate an array of ints. What's wrong with this code?
int array[5], i, *ip;
for(i = 0; i < 5; i++) array[i] = i;
ip = array;
printf("%d\n", *(ip + 3 * sizeof(int)));
I expected the last line to print 3, but it printed garbage. for(i = 0; i < 5; i++) array[i] = i;
ip = array;
printf("%d\n", *(ip + 3 * sizeof(int)));
5)I have a char * pointer that happens to point to some ints, and I want to step it over them. Why doesn't ((int *)p)++; work?
6)Why can't I perform arithmetic on a void * pointer?
7)I've got some code that's trying to unpack external structures, but it's crashing with a message about an ``unaligned access.'' What does this mean?
8)I have a function which accepts, and is supposed to initialize, a pointer:
void f(int *ip)
{
static int dummy = 5;
ip = &dummy;
}
But when I call it like this:
int *ip;
f(ip);
the pointer in the caller remains unchanged. {
static int dummy = 5;
ip = &dummy;
}
But when I call it like this:
int *ip;
f(ip);
9)Suppose I want to write a function that takes a generic pointer as an argument and I want to simulate passing it by reference. Can I give the formal parameter type void **, and do something like this?
void f(void **);
double *dp;
f((void **)&dp);
10)I have a function extern int f(int *);double *dp;
f((void **)&dp);
which accepts a pointer to an int. How can I pass a constant by reference? A call like
f(&5);
doesn't seem to work.
11)Does C even have ``pass by reference''?
12)I've seen different syntax used for calling functions via pointers. What's the story?
13)What's the total generic pointer type? My compiler complained when I tried to stuff function pointers into a void *.
14)How are integers converted to and from pointers? Can I temporarily stuff an integer into a pointer, or vice versa?
15)How do I convert an int to a char *? I tried a cast, but it's not working.
16)What's wrong with this declaration?
char* p1, p2;
I get errors when I try to use p2.
17)What are ``near'' and ``far'' pointers?
keywords:
c interview questions
c++ faq
faq on pointers in c
faq on arrays in c
faq videos
c tutorial
faqs on strings in c
steve summit
faq on pointers in c
faq on arrays in c
c++ faq
programming in c textbook
c tutorial
c programming resources
c language reference
cinterviews.com
use of pointers in c
pointer in c example
pointers in c pdf
use of pointers in c++
types of pointers in c
pointers in c geeks for geeks
double pointers in c
what is pointer in c
advantages of pointers in c
pointers to manipulate an array of ints
arithmetic operations on void pointers
void pointer function
void pointer in c++
pointer arithmetic
cast void pointer to int
void*' is not a pointer-to-object type
how to print void pointer value in c
generic pointer in c
(void *) in c
convert pointer to integer c++
how to convert pointer into integer
int to pointer cast warning
integer to pointer casting
c++ get pointer as integer
conversion from pointer to smaller integer
how to convert char pointer to integer in c
uintptr_t
c faqs
C faqs
Question1: Difference between arrays and pointers?Answer: Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them
Arrays use subscripted variables to access and manipulate data. Array variables can be equivalently written using pointer expression.
Question2: What is the purpose of realloc ( )?
Answer: The function realloc (ptr,n) uses two arguments. The first argument ptr is a pointer to a block of memory for which the size is to be altered. The second argument n specifies the
new size. The size may be increased or decreased. If n is greater than the old size and if sufficient space is not available subsequent to the old region, the function realloc ( )
may create a new region and all the old data are moved to the new region.
Question3: What is static memory allocation and dynamic memory allocation?
Answer: Static memory allocation: The compiler allocates the required memory space for a declared variable. By using the address of operator, the reserved address is obtained and this address may be assigned to a pointer variable. Since most of the declared variable has static memory, this way of assigning pointer value to a pointer variable is known as static memory allocation. Memory is assigned during compilation time.
Dynamic memory allocation: It uses functions such as malloc ( ) or calloc ( ) to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these functions are assigned to pointer variables, such assignments are known as dynamic memory allocation. Memory is assigned during run time.
Question4: How are pointer variables initialized?
Answer: Pointer variable are initialized by one of the following two ways
Ø Static memory allocation
Ø Dynamic memory allocation
Question5: What is a pointer variable?
Answer: A pointer variable is a variable that may contain the address of another variable or any valid address in the memory.
Question6: What is a pointer value and address?
Answer: A pointer value is a data object that refers to a memory location. Each memory location is numbered in the memory. The number attached to a memory location is called the address of the location.
Keywords:
difference between arrays and pointers
purpose of realloc in c
static memory allocation and dynamic memory allocation in c
pointer variable initialization in cpointer variable in c
what is a pointer value and address in c
difference between array and pointer in c in tabular form
differentiate between array of pointers and pointers to array
relation between array and pointer in c
difference between array and pointer in c in hindi
array of pointers in c
difference between array and pointer in hindi
which of arrays or pointers are faster
difference between array and structure
static memory allocation in c geeksforgeeks
difference between static and dynamic memory allocation? - quora
advantages and disadvantages of static and dynamic memory allocation
dynamic memory allocation in c++
static memory allocation in c++ with example program
when is memory allocated and deallocated in c? answer both static and dynamic memory.
static and dynamic memory in computer organization
dynamic memory allocation in c pdf
declaration and initialization in c
how to initialize a pointer c++
accessing a variable through its pointer
pointer arithmetic in c
pointer to pointer in c
pointer and array in c
pointer operator in c
pointer assignment in c
pointer in c example
pointers in c pdf
use of pointers in c
double pointers in c
types of pointers in c
pointers in c geeks for geeks
list of c programs on pointers
pointers and arrays in c
use of pointers in c
pointers in c geeks for geeks
list of c programs on pointers
what is pointer in c++
pointers in c pdf
pointer in c example
types of pointers in c
double pointers in c
Subscribe to:
Posts (Atom)