Can somebody please tell me what I am doing wrong??
First mistake that I can notice is in scanf, for string with %s
you are using &
:
scanf("%s", &filename);
^
|
remove it, undefined behavior
it should be just:
scanf("%s", filename);
your code will not work after this. I can't find any other syntax error so I believe this is the main bug in your code.