Plz answer to my C doubts:-
1) Why do prototypes of some predefined functions in ctype.h(ex- tolower(ch)) has 'int' as the data type for formal arguments? How will it matter if the formal arguments r of type 'char'?
2) Is there any command in DOS for viewing the non printable characters stored in a file.
char *p="Hello" //Where will be this "Hello" stored??????
int *p; *p=2;
My old compiler doesnt give any error for this code. But is it realy valid???? Does it give error in ur compiler????? Plz explain where is the value 2 stored.
5) Why is using 'gets' dangerous(as 'C' compiler in UNIX warns)?
6) exp1 = (type_cast) exp2
In 'C' do we have to type cast exp2 to the datatype of exp1 explicitly? Or is it ALWAYS done implicitly by the 'C' compiler?
Is it same with C++ also?
7) Is a buffer always used while writing or reading from a file in 'C'?
If yes, then when do we need to make a call to setvbuf with 'buf=NULL' since the 'C' compiler always assigns a buffer automatically(according to u)?
8) In 'C' we hav 'eof' and 'error' flags for indicating the errors which occur while doing file operations.
Suppose i try to call some file handling function and an error occurs(end of file doesnt occur) , how these 2 flags will be affected? If i m not wrong, error flag will set. But is eof flag affected(or set or reset)?
Will every file handling function in C affect both the flags?
Will every function in C affect both the flags?
I was reading Kernighan & Ritchie and couldnt understand few things can u plz explain them:-
9) For expalnation of getc its written that
int getc(FILE *stream)
getc is equivalent to fgetc except that if it
is a macro, it may evaluate stream more than
Here what is the meaning of 'it may evaluate stream more than once' ? And which one shd we prefer to use- fgetc or getc?
10) For expalnation of setvbuf its written that
"It must be called before reading, writing, or any other operation."
What does this mean? Does it mean if i make a call to setvbuf with 'buf = not NULL' then the buffering will stop after doing one file handling operation?
11) There is one statement:- "fflush must be called between a read and a write or vice versa."
Can u plz give reason for doing so bcoz i think fflush is needed only when some data is left unwritten inside a buffer even after making a call to one of the write operations.
Thanx in advance.