⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testfopen.c

📁 微软的基于HMM的人脸识别原代码, 非常经典的说
💻 C
字号:
#include "stdio.h"
#include "string.h"
#include "fcntl.h"

void test7(void)
{
    FILE * fp;
    int len;
    char cmd[50]; 
    
    fp = popen("/usr/bin/gnuplot","w");
    if (fp == NULL) {
	fprintf(stderr,"Problems\n");
	return;
    }

    while(1) {
	printf("Input command:>");
	fflush(stdout);
	gets(cmd);
	printf("comand is %s\n",cmd);
	if((len = strlen(cmd)) > 1) {
	    fputs(cmd,fp);
	    fputc('\n',fp);
	    fflush(fp);
	} else
	    break;
    }
    printf(" close status = %d\n",pclose(fp));
}



void test6(void)
{

    FILE *fp;
    int count; float quant; char units[21], item[21];
    int i;
    
    fp = fopen("/tmp/xxeicxx","w+");
    fputs("2 quarts of oil\n"
	  "-12.8 degrees Celsius\n"
	  "lots of luck\n"
	  "10.0LBS       of\n"
	  "dirt\n"
	  "100ergs of energy",
	  fp);
    fseek(fp,0L,SEEK_SET);
    i = 0;
    while(!feof(fp) && i < 10) {
	units[0] = item[0] ='\0';
	count = fscanf(fp,"%f%20s of %20s",&quant, units, item);
	fscanf(fp,"%*[^\n]");
	printf("count = [%d]  quant = [%g] units = [%s] item = [%s]\n",
	       count,quant,units,item);
       ++i;
    }
    fclose(fp);

}



void test5(void)
{
    fprintf(stdout,"%s = %b\n","binary 100", 100);
    fprintf(stdout,"|%!15.2f|\n", 13.3333);
}

void test4(void)
{
    int i;
    char *buf = "Hello world Hello world Hello world Hello world\n";
    for(i=0;buf[i] != '\0'; ++i)
	fputc(buf[i],stdout);

    fputs(buf,stdout);
    
}

int main(void)
{
    test6();
    test5();
    test4();
    return 0;
}








⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -