void write_file(void)
{
FILE *fp;
//char * pn="/storage/emulated/0/h.c";
char pn[PN_VALURE];/*Cannot
exceed PA_VALURE-1Bytes.*/
//char ch;
int ch;//转用 int 类型比较好一点。因为getc()和putc()都使用int类型。
printf("input path and name of file (ESC Key exit):\n");
scanf("%s", pn);
//char wfch;
//wfch=getc(stdin);
if(pn[0] == 27)/*27 is ESC Key ascii code value*/
{
printf("\"write file\" function exited.\n\n");
return;
}
/*有时即使被调用函数是void类型 被调函数中的return也不是毫无意义的*/
/*这里的return其实还有个退出该函数,而并不退出整个程序的作用!*/
else
fp=fopen(pn, "a+b");
printf("input text of file:\n");
printf("input ESC key to exit. ( Android phone is vol up + e at English mode )\ninput F4 Key saved to disk. (Android phone is vol up + r at English mode)\n");
ch=getc(stdin);/*get scanf() tail char in stdin.*/
if(ch=='\n')/*process scanf() tail Enter Key. Avert input to in file.*/
/*Certainly also have other method. Such as struct stdin from FILE*/
{
ch = '\0';
//putc(ch, NULL);//Okay.
putc(ch, stderr);/*Direct not bufer i input to screen*/
}
unsigned int character_count = 0;//这个变量不需要太多空间。
//因为它不会超过全缓冲的大小(超过了也没有意义)。全缓冲一般4096字节。一旦4096写满了。会自动刷新。
//fopen()它开辟的是一个全缓冲,根据操作系统不同而设定字节大小。一般为4096字节。
//我们设定当写入10字节符号时,刷新fp指向的全缓冲。
while (true)
{
{
FILE *fp;
//char * pn="/storage/emulated/0/h.c";
char pn[PN_VALURE];/*Cannot
exceed PA_VALURE-1Bytes.*/
//char ch;
int ch;//转用 int 类型比较好一点。因为getc()和putc()都使用int类型。
printf("input path and name of file (ESC Key exit):\n");
scanf("%s", pn);
//char wfch;
//wfch=getc(stdin);
if(pn[0] == 27)/*27 is ESC Key ascii code value*/
{
printf("\"write file\" function exited.\n\n");
return;
}
/*有时即使被调用函数是void类型 被调函数中的return也不是毫无意义的*/
/*这里的return其实还有个退出该函数,而并不退出整个程序的作用!*/
else
fp=fopen(pn, "a+b");
printf("input text of file:\n");
printf("input ESC key to exit. ( Android phone is vol up + e at English mode )\ninput F4 Key saved to disk. (Android phone is vol up + r at English mode)\n");
ch=getc(stdin);/*get scanf() tail char in stdin.*/
if(ch=='\n')/*process scanf() tail Enter Key. Avert input to in file.*/
/*Certainly also have other method. Such as struct stdin from FILE*/
{
ch = '\0';
//putc(ch, NULL);//Okay.
putc(ch, stderr);/*Direct not bufer i input to screen*/
}
unsigned int character_count = 0;//这个变量不需要太多空间。
//因为它不会超过全缓冲的大小(超过了也没有意义)。全缓冲一般4096字节。一旦4096写满了。会自动刷新。
//fopen()它开辟的是一个全缓冲,根据操作系统不同而设定字节大小。一般为4096字节。
//我们设定当写入10字节符号时,刷新fp指向的全缓冲。
while (true)
{
