FreeJobAlert.Com

Government Jobs | Results | Admit Cards

c language interview questions | Part9

If you would like to view All C language interview questions only at one place visit below link
All C Language Interview Questions

81. What is a file pointer?
Ans: The pointer to a FILE data type is called as a stream pointer or a file pointer. A file pointer points to the block of information of the stream that had just been opened.

82. How is fopen()used ?
Ans: The function fopen() returns a file pointer. Hence a file pointer is declared and it is assigned
as
FILE *fp;
fp= fopen(filename,mode);
filename is a string representing the name of the file and the mode represents:
“r” for read operation
“w” for write operation
“a” for append operation
“r+”,”w+”,”a+” for update operation

83How is a file closed ?
Ans: A file is closed using fclose() function
Eg. fclose(fp);
Where fp is a file pointer.

84. What is a random access file?
Ans:
A file can be accessed at random using fseek() function
fseek(fp,position,origin);
fp file pointer
position number of bytes offset from origin
origin 0,1 or 2 denote the beginning ,current position or end of file respectively.

85. What is the purpose of ftell ?
Ans: The function ftell() is used to get the current file represented by the file pointer.
ftell(fp);
returns a long integer value representing the current file position of the file pointed by the
file pointer fp.If an error occurs ,-1 is returned.

86. What is the purpose of rewind() ?
Ans: The function rewind is used to bring the file pointer to the beginning of the file.
Rewind(fp);
Where fp is a file pointer.Also we can get the same effect by
feek(fp,0,0);

87. Difference between a array name and a pointer variable?
Ans: A pointer variable is a variable where as an array name is a fixed address and is not a
variable. A
pointer variable must be initialized but an array name cannot be initialized. An array name being a constant value , ++ and — operators cannot be applied to it.

88. Represent a two-dimensional array using pointer?
Ans:
Address of a[I][j] Value of a[I][j]
&a[I][j]
or
a[I] + j
or
*(a+I) + j
*&a[I][j] or a[I][j]
or
*(a[I] + j )
or
*( * ( a+I) +j )

89. Difference between an array of pointers and a pointer to an array?
Ans:
Array of pointers
1- Declaration is: data_type *array_name[size];
2-Size represents the row size.
3- The space for columns may be dynamically

Pointers to an array
1-Declaration is data_type ( *array_name)[size];
2-Size represents the column size.

90. Can we use any name in place of argv and argc as command line arguments ?
Ans: yes we can use any user defined name in place of argc and argv;

Related Fresher Interview Questions

1. C Language Interview Questions
2. C++ Language Interview Questions
3. Data Structures Interview Questions
4. DBMS Interview Questions
5. Operating System Interview Questions
6. UNIX Interview Questions

Tags: c fresher interview questions, c interview, c interview questions, c interview questions for freshers, c interview questions with answers, c language interview questions, c language interview questions and answers, fresher interview questions, fresher interview questions and answers, fresher interview questions and answers on c, fresher interview questions on c, fresher interview questions with answers, interview questions on c, it fresher interview questions, it fresher interview questions and answers, questions for interview, questions on c

Leave a Comment