You cannot compare strings using =
(or even by ==
, for that matter) operator. You need to use strcmp()
for that.
In your code, inside mobileno()
function,
if( s="katrina" )
is essentially trying to assign the base address of the string literal "katrina"
to s
. It is nowhere near a comparison.
That said,
- Never use
gets()
, it suffer from buffer overflow problem. Use the safer alternative,fgets()
- Recommended signature of
main()
isint main(void)
solved why the following code gives the first mobile no. irrespective of name