Having a problem with reading and writing a file character by character

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
FILE *fp;
char fname[20];
char ch;
printf("\n enter file name to create:");
scanf("%s",fname);
fp=fopen(fname,“w”);
if(fp==NULL)
{
printf(“File not created”);
exit(0);
}
printf(“file created successfully”);
printf("|n enter text to write (press to save and quit):\n");
while((ch=getchar())!=’\n’)
{
putc(ch,fp);
}
printf(“Data written successfully”);
fclose(fp);
fp=fopen(fname,“r”);
if(fp==NULL)
{
printf("\n cant open file!!");
exit(0);
}
printf("\n content of file is\n");
while((ch=getc(fp))!=EOF)
{
printf("%c",ch);
}
fclose(fp);
return 0;
}
also i wanted to know where the file is stored which has been created ??

i am not able to write in the file. basically the while part is not working i think

After typing the name of the file , you press enter. So everything before enter is stored in the string and the getchar() function in the while loop reads this newline character. Since a newline is stored in ch, the condition of loop becomes false and the loop terminates without writing data to the file.

#include<conio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
FILE *fp;
char fname[20];
char ch='\n';
printf("\n enter file name to create:");
scanf("%s",fname);
fp=fopen(fname,"w");
if(fp==NULL)
{
printf("File not created\n");
exit(0);
}
printf("file created successfully\n");
printf("|n enter text to write (press to save and quit):\n");
//while(ch=='\n')
	scanf(" %c",&ch);

while(ch!='\n')
{
	fputc(ch,fp);
	scanf("%c",&ch);

}
printf("Data written successfully");
fclose(fp);
fp=fopen(fname,"r");
if(fp==NULL)
{
printf("\n cant open file!!");
exit(0);
}
printf("\n content of file is\n");
while((ch=fgetc(fp))!=EOF)
{
printf("%c",ch);
}
fclose(fp);
return 0;
}

scanf(" %c",&ch);
Using the above statement after taking input for the file name, The first character other than a white space is stored in ch. (The space before %c makes it ignore whitespaces which include newline and tabs.)
Then the while loop compares this value of ch with newline.
Then after writing the character to the file again scanf is used but this time without the space before %c so that newline doesn’t get ignored.