• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ efopen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中efopen函数的典型用法代码示例。如果您正苦于以下问题:C++ efopen函数的具体用法?C++ efopen怎么用?C++ efopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了efopen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: load

static Proto* load(const char* filename)
{
 Proto* tf;
 ZIO z;
 char source[512];
 FILE* f;
 int c,undump;
 if (filename==NULL) 
 {
  f=stdin;
  filename="(stdin)";
 }
 else
  f=efopen(filename,"r");
 c=ungetc(fgetc(f),f);
 if (ferror(f))
 {
  fprintf(stderr,"luac: cannot read from ");
  perror(filename);
  exit(1);
 }
 undump=(c==ID_CHUNK);
 if (undump && f!=stdin)
 {
  fclose(f);
  f=efopen(filename,"rb");
 }
 sprintf(source,"@%.*s",Sizeof(source)-2,filename);
 luaZ_Fopen(&z,f,source);
 tf = undump ? luaU_undump(L,&z) : luaY_parser(L,&z);
 if (f!=stdin) fclose(f);
 return tf;
}
开发者ID:Akagi201,项目名称:learning-lua,代码行数:33,代码来源:luac.c


示例2: ttyin

char ttyin(void) {
	char buf[BUFSIZ];
	FILE *efopen();
	static FILE *tty = NULL;

	if (tty == NULL) {
		tty = efopen("/dev/tty", "r");
}
	else if (fgets(buf, BUFSIZ, tty) == NULL || buf[0] =='q') {
		exit(0);
}
	else {
		return buf[0];
}
}
开发者ID:cheetah0216,项目名称:hnreader,代码行数:15,代码来源:p.c


示例3: main

int 
main(int argc, char **argv)
{
	/* Segy data constans */
	int ntr=0;		/* number of traces			*/
	char *outpar=NULL;	/* name of file holding output		*/
	FILE *outparfp=stdout;	/* ... its file pointer			*/

	initargs(argc, argv);
   	requestdoc(1);
	
	/* Get information from the first header */
	if (!gettr(&tr)) err("can't get first trace");
	if (!getparstring("outpar", &outpar))	outpar = "/dev/stdout" ;
	
	outparfp = efopen(outpar, "w");

        checkpars();
	/* Loop over traces getting a count */
	do {
		++ntr;
	} while(gettr(&tr));

	fprintf(outparfp, "%d", ntr);

	return(CWP_Exit());

}
开发者ID:JohnWStockwellJr,项目名称:SeisUnix,代码行数:28,代码来源:sutrcount.c


示例4: afa_out

int afa_out (Options * options, Alignment * alignment) {

    int i, pos;
    char * seq;
    FILE * fptr;
    char filename[BUFFLEN];
 
    sprintf (filename, "%s.patched.afa", options->outname);

    fptr = efopen (filename, "w");
    if (!fptr) return 1;
    
    for (i=0; i<alignment->number_of_seqs; i++) {
	
	fprintf ( fptr,  ">%s\n", alignment->name[i]);
	seq = alignment->sequence[i];
	
	for (pos=0; pos<alignment->length; pos++) {
	    if ( seq [pos] == '.' ) {
		/* seaview doesn't like dots */
		fprintf ( fptr,  "-");
	    } else {
		fprintf ( fptr,  "%c",  seq [pos]);
	    }
	    if ( pos%50 == 49 ) fprintf (fptr, "\n");
	}
	if ( pos%50 ) fprintf (fptr, "\n");
  
    }
    fclose (fptr);
    
    return 0;
}
开发者ID:ivanamihalek,项目名称:hypercube,代码行数:33,代码来源:hc_afa_out.c


示例5: ecalloc

/* Lê o ficheiro de configuração dos jogadores
 * Numero de baralhos e jogadores
 */
Config *read_config(char *filename)
{
	char buffer[MAX_LINE_LEN];

	Config *config = NULL;
	config = (Config *) ecalloc((size_t) 1, sizeof(Config));

	FILE *config_file = efopen(filename, "r");

    // Parametros gerais de configuração:
    // Número de jogadores e numero de baralhos
	fgets(buffer, MAX_LINE_LEN, config_file);
	sscanf(buffer, "%d-%d", &(config->num_decks), &(config->num_players));

	if (config->num_decks > 8 || config->num_decks < 4){
		fprintf(stderr, "Erro: número de baralhos invalido.\n");
		exit(EXIT_FAILURE);
	}

	if (config->num_players > 4 || config->num_players < 1) {
		fprintf(stderr, "Erro: número de jogadores invalido.\n");
		exit(EXIT_FAILURE);
	}
    // Leitura dos parâmetros de configuracão de cada jogador
	for (int i=0; fgets(buffer, MAX_LINE_LEN, config_file) != NULL && i < config->num_players; i++)
		config = read_player(buffer, config, i);

	fclose(config_file);

	return config;
}
开发者ID:joajfreitas,项目名称:blackjack,代码行数:34,代码来源:file.c


示例6: main

int
main(
	int  argc,
	char  **argv
)
{
	FILE  *fp;

	progname = *argv++;
	argc--;

	init(progname);
	if (argc)
		while (argc)  {
			fp = efopen(*argv, "r");
			plot(fp);
			fclose(fp);
			argv++;
			argc--;
		}
	else
		plot(stdin);

	if (!newpage)
		endpage();

	done();
	return(0);
}
开发者ID:Pizookies,项目名称:Radiance,代码行数:29,代码来源:psmeta.c


示例7: main

int main(int argc, char *argv[]){
  int i;
  char *version;
  Args *args;
  FILE *fp;

  version = "0.3";
  setprogname2("inspectPro");
  args = getArgs(argc, argv);
  if(args->v)
    printSplash(version);
  if(args->h || args->e)
    printUsage(version);
  if(args->numInputFiles == 0){
    fp = stdin;
    scanFile(fp, args);
  }else{
    for(i=0;i<args->numInputFiles;i++){
      fp = efopen(args->inputFiles[i],"rb");
      scanFile(fp, args);
      fclose(fp);
    }
  }
  free(args);
  free(progname());
  return 0;
}
开发者ID:CIPaGES,项目名称:InspectPro,代码行数:27,代码来源:inspectPro.c


示例8: main

int
main(
	int  argc,
	char  *argv[]
)
{
	FILE  *fp;
	int  i;

	progname = argv[0];

	pout = popen(OUTFILT, "w");

	if (argc > 1)
		for (i = 1; i < argc; i++) {
			fp = efopen(argv[i], "r");
			plot4(fp);
			fclose(fp);
		}
	else
		plot4(stdin);
	
	pglob(PEOF, 0200, NULL);

	return(pclose(pout));
}
开发者ID:MITSustainableDesignLab,项目名称:Daysim,代码行数:26,代码来源:plot4.c


示例9: efopen

char *string_file(const char *fname) {
/*
 * read file in dynamically allocated character string
 */
	FILE *in = NULL;
	char *buf = NULL, cr;
	int c;
	int buf_size = 1000, i = 0;

	/* read as ascii file */
	in = (fname == NULL) ? (FILE *) stdin : efopen(fname, "r");
	buf = (char *) emalloc(buf_size * sizeof(char));
	while ((c = fgetc(in)) != EOF) {
		cr = c;
		convert_null_to_space(&cr, fname ? fname : "stdin", NULL);
		if (i == buf_size) {
			buf_size += 1000;
			buf = (char *) erealloc(buf, buf_size * sizeof(char));
		}
		buf[i] = c;
		i++;
	}
	buf[i] = '\0'; /* close string */
	if (fname != NULL)
		efclose(in); /* close file */
	/* free unnecesary memory: */
	return (char *) erealloc(buf, (i + 1) * sizeof(char));
}
开发者ID:Andlon,项目名称:cs267FinalProject,代码行数:28,代码来源:utils.c


示例10: main

int main(int argc, char*argv[]) {

    // the graph is just a list og from to identifier pairs, one per line
    if (argc != 4) {
	fprintf (stderr, "Usage: %s  <path to graph>  <from id>  <to id>\n", argv[0]);
	exit(1);
    }
    
    // 57572 DOCK6
    // 7049 TGFBR3
    // 2263 FGFBP3
    igraph_vs_t  vertex_to; 
    igraph_integer_t vertex_from;
    vertex_from = atol(argv[2]);
    // in principle, unumber of "to" vertices is arbitrary,
    // but that is a piece of code I will write some other time
    //igraph_vs_vector_small(&vertex_to, 2263, 7049,  -1);
    igraph_vs_vector_small(&vertex_to, atol(argv[3]),  -1);
   
    igraph_t graph;
    /*The number of vertices in the graph. If smaller than the largest integer in
      the file it will be ignored. It is thus safe to supply zero here. */
    igraph_integer_t zero = 0;

    FILE * infile  =  efopen(argv[1], "r") ;
    
    igraph_bool_t directed  = IGRAPH_UNDIRECTED;
    igraph_read_graph_edgelist (&graph, infile,  zero, directed);

    /* shortest path calculation: */
    /* http://igraph.org/c/doc/igraph-Structural.html#igraph_get_all_shortest_paths
       int igraph_get_all_shortest_paths(const igraph_t *graph,
				  igraph_vector_ptr_t *res, 
				  igraph_vector_t *nrgeo,
				  igraph_integer_t from, const igraph_vs_t to,
				  igraph_neimode_t mode);
    */
    igraph_vector_ptr_t result;
    igraph_vector_t nrgeo;
    igraph_integer_t i;
    // the second argument here is the number of "to"  vertices
    igraph_vector_ptr_init (&result, 1);
    igraph_vector_init(&nrgeo, 0);
    igraph_get_all_shortest_paths (&graph, &result, &nrgeo,
			    vertex_from,  vertex_to,
			   IGRAPH_ALL);
    for (i=0; i<igraph_vector_ptr_size(&result); i++) {
	print_vector(VECTOR(result)[i]);
    }

    igraph_vector_ptr_destroy(&result);
    igraph_vs_destroy(&vertex_to);
    igraph_destroy(&graph);

    if (!IGRAPH_FINALLY_STACK_EMPTY) return 1;
  
    return 0;
}
开发者ID:ivanamihalek,项目名称:c-utils,代码行数:58,代码来源:shortest_path.c


示例11: main

int
main(int argc, char **argv)
{
	cwp_String key1,  key2;	/* x and y key header words	*/
	Value  val1,  val2;	/* ... their values		*/
	cwp_String type1, type2;/* ... their types		*/
	int index1, index2;	/* ... their indices in hdr.h	*/
	float x, y;		/* temps to hold current x & y 	*/
	cwp_String outpar;	/* name of par file		*/
	register int npairs;	/* number of pairs found	*/


	/* Hook up getpars */
	initargs(argc, argv);
	requestdoc(1);


	/* Prevent byte codes from spilling to screen */
	if (isatty(STDOUT)) err("must redirect or pipe binary output");


	/* Get parameters */
	if (!getparstring("key1", &key1))	key1 = "sx";
	if (!getparstring("key2", &key2))	key2 = "gx";

	type1 = hdtype(key1);
	type2 = hdtype(key2);

	index1 = getindex(key1);
	index2 = getindex(key2);


	/* Loop over traces */
	npairs = 0;
	while(gettr(&tr)) {

		gethval(&tr, index1, &val1);
		gethval(&tr, index2, &val2);

		x = vtof(type1, val1);
		y = vtof(type2, val2);

		efwrite(&x, FSIZE, 1, stdout);
		efwrite(&y, FSIZE, 1, stdout);

		++npairs;
	}


	/* Make parfile if needed */
	if (getparstring("outpar", &outpar))
		fprintf(efopen(outpar, "w"),
			"n=%d label1=%s label2=%s\n",
			npairs, key1, key2);

	return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:57,代码来源:suchart.c


示例12: treemerge

static void
treemerge(	/* merge into one file */

int  height, int nt, int nf,
PLIST  *pl,
int  (*pcmp)(),
FILE  *ofp
)
{
    FILE  *fi[NFILES], *fp;
    int  i;
    
    if (nf <= NFILES) {

	for (i = 0; i < nf; i++)
	    fi[i] = efopen(tfname(height, i + nt*NFILES), "r");
	
	if ((fp = ofp) == NULL)
	    fp = efopen(tfname(height + 1, nt), "w");
	
	pmergesort(fi, nf, pl, pcmp, fp);
	
	for (i = 0; i < nf; i++) {
	    fclose(fi[i]);
	    unlink(tfname(height, i + nt*NFILES));
	}
	if (ofp == NULL) {
	    writeof(fp);
	    fclose(fp);
	}
	
    } else {
    
        for (i = 0; i < (nf-1)/NFILES; i++)
            treemerge(height, i, NFILES, NULL, pcmp, NULL);
            
	treemerge(height, (nf-1)/NFILES, (nf-1)%NFILES + 1, pl, pcmp, NULL);

	treemerge(height + 1, 0, (nf-1)/NFILES + 1, NULL, pcmp, ofp);
            
    }

}
开发者ID:Pizookies,项目名称:Radiance,代码行数:43,代码来源:sort.c


示例13: ttyin

ttyin()	/* process response from /dev/tty (version 2) */
{
	char buf[BUFSIZ];
	FILE *efopen();
	static FILE *tty = NULL;

	if (tty == NULL)
		tty = efopen("/dev/tty", "r");
	for (;;) {
		if (fgets(buf,BUFSIZ,tty) == NULL || buf[0] == 'q')
			exit(0);
		else if (buf[0] == '!') {
			system(buf+1);	/* BUG here */
			printf("!\n");
		}
		else	/* ordinary line */
			return buf[0];
	}
}
开发者ID:harvintoledo,项目名称:hamat,代码行数:19,代码来源:ttyin2.c


示例14: main

int
main(int argc, char **argv)
{
	float fz[BUFSIZ];
	int iz=0,jz,nz=0;
	unsigned int z[BUFSIZ];
	char line[BUFSIZ],*lp, *outpar;
	FILE *infp=stdin,*outfp=stdout, *outparfp;

	unsigned int *uz = &(z[0]);

	/* Hook up getpar */
	initargs(argc, argv);
	requestdoc(1);

	/* Prevent floats from dumping on screen */
	switch(filestat(STDOUT)) {
	case BADFILETYPE:
		warn("stdout is illegal filetype");
		pagedoc();
	break;
	case TTY:
		warn("stdout can't be tty");
		pagedoc();
	break;
	default: /* rest are OK */
	break;
	}


	/* Get parameters and do set up */
	if (!getparstring("outpar", &outpar))  outpar = "/dev/tty" ;
	outparfp = efopen(outpar, "w");

	while (fgets(line,BUFSIZ,infp)!=NULL) {

		/* set pointer to beginning of line */
		lp = line;

		/* read hex digits from input line */
		for(iz=0;sscanf(lp,"%2x",&uz[iz])==1;iz++,nz++,lp+=2);

		/* convert to floats */
		for(jz=0;jz<iz;jz++)
			fz[jz] = 255-z[jz];

		/* write floats */
		fwrite(fz,sizeof(float),iz,outfp);
	}

	/* Make par file */
	fprintf(outparfp, "total number of values=%d\n",nz);

	return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:55,代码来源:h2b.c


示例15: doit

static void doit(int undump, char* filename)
{
 FILE* f= (filename==NULL) ? stdin : efopen(filename, undump ? "rb" : "r");
 ZIO z;
 char source[255+2];			/* +2 for '@' and '\0' */
 luaL_filesource(source,filename,sizeof(source));
 zFopen(&z,f,source);
 if (verbose) fprintf(stderr,"%s\n",source+1);
 if (undump) do_undump(&z); else do_compile(&z);
 if (f!=stdin) fclose(f);
}
开发者ID:Akagi201,项目名称:learning-lua,代码行数:11,代码来源:luac.c


示例16: doit

static void doit(int undump, char* filename)
{
    FILE* f= (filename==NULL) ? stdin : efopen(filename, undump ? "rb" : "r");
    ZIO z;
    if (filename==NULL) filename="(stdin)";
    zFopen(&z,f,filename);
    if (verbose) fprintf(stderr,"%s\n",filename);
    if (undump) do_undump(&z);
    else do_compile(&z);
    if (f!=stdin) fclose(f);
}
开发者ID:jeske,项目名称:hz,代码行数:11,代码来源:luac.c


示例17: scanwma

void
scanwma(struct fidinfo *fidinfo, struct statex *statex)
{
	FILE	*fp;

	fp = efopen(statex->path, "r");
	if (asf_check_header(statex, fp))
		read_asf_header(fidinfo, statex, fp);
	else
		fidinfo->scanned = 0;
	fclose(fp);
}
开发者ID:elperepat,项目名称:mp3tofid,代码行数:12,代码来源:scanwma.c


示例18: main

int
main(int argc, char **argv)
{
	double sx, sy, gx, gy, factor;
	float mx, my;
        short unit;                                                           
	int degree;
	cwp_String outpar;
	register int npairs;


	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);

	if (!getparint("degree", &degree)) degree=0;

	npairs = 0;
	while (gettr(&tr)) {

		sx = tr.sx;
		sy = tr.sy;
		gx = tr.gx;
		gy = tr.gy;

                unit = tr.counit;
		
		/* If tr.scalco not set, use 1 as the value */
		factor = (!tr.scalco) ? 1 : tr.scalco;
		
                /* factor < 0 means divide; factor > 0 means to multiply */
                if (factor < 0) factor = -1/factor;

                /* if necessary, convert from seconds to degrees */
                if (unit == 2 && degree == 1) factor /= 3600;

                mx = (float) (0.5*(sx + gx) * factor);
                my = (float) (0.5*(sy + gy) * factor);

		efwrite(&mx, FSIZE, 1, stdout);
		efwrite(&my, FSIZE, 1, stdout);

		++npairs;
	}


	/* Make parfile if needed */
	if (getparstring("outpar", &outpar))
		fprintf(efopen(outpar, "w"), "n=%d\n", npairs);

	return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:52,代码来源:su3dchart.c


示例19: main

int
main(int argc, char **argv)
{
	char *outpar;		/* name of file holding output parfile	*/
	FILE *outparfp;		/* ... its file pointer			*/
	int n1;			/* number of floats per line		*/
	size_t n1read;		/* number of items read			*/
	size_t n2 = 0;		/* number of lines in input file 	*/
	float *z;		/* binary floats			*/

	/* Hook up getpar */
	initargs(argc, argv);
	requestdoc(1);

	/* Get parameters and do set up */
	if (!getparstring("outpar", &outpar))	outpar = "/dev/tty" ;
	outparfp = efopen(outpar, "w");
	MUSTGETPARINT("n1",&n1);

	z = ealloc1float(n1);

	/* Loop over data converting to ascii */
	while ((n1read = efread(z, FSIZE, n1, stdin))) {
		register int i1;

		if (n1read != n1)
			err("out of data in forming line #%d", n2+1);
		for (i1 = 0; i1 < n1; ++i1)
/* z2xyz.c:70: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘size_t’ */
/* 			printf("%d %d %11.4e \n",n2,i1,z[i1]); */
#if __WORDSIZE == 64
			printf("%lu %d %11.4e \n",n2,i1,z[i1]);
#else
			printf("%u %d %11.4e \n",n2,i1,z[i1]);
#endif
		++n2;
	}


	/* Make par file */
/* z2xyz.c:76: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’ */
/* 	fprintf(outparfp, "n2=%d\n", n2); */
#if __WORDSIZE == 64
	fprintf(outparfp, "n2=%lu\n", n2);
#else
	fprintf(outparfp, "n2=%u\n", n2);
#endif

	return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:50,代码来源:z2xyz.c


示例20: getargs

static void getargs (int    argc   ,
		     char** argv   ,
		     FILE** avgfile,
		     FILE** fldfile)
/* ------------------------------------------------------------------------- *
 * Parse command-line arguments.
 * ------------------------------------------------------------------------- */
{
  char usage[] = "usage: rstress [options] avg.file [field.file]\n"
                 "options:\n"
                 "  -h ... display this message\n";
  char err[STR_MAX], c;

  while (--argc && **++argv == '-')
    switch (c = *++argv[0]) {
    case 'h':
      fprintf (stderr, usage); exit (EXIT_SUCCESS);
      break;
    default:
      sprintf (err, "illegal option: %c\n", c);
      message (prog, err, ERROR);
      break;
    }

  switch (argc) {
  case 1:
    *avgfile = efopen (argv[0], "r");
    break;
  case 2:
    *avgfile = efopen (argv[0], "r");
    *fldfile = efopen (argv[1], "r");
    break;
  default:
    fprintf (stderr, usage); exit (EXIT_FAILURE);
    break;
  }  
}
开发者ID:jueqingsizhe66,项目名称:MrWang,代码行数:37,代码来源:rstress.c



注:本文中的efopen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ efread函数代码示例发布时间:2022-05-30
下一篇:
C++ efi_enabled函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap