[Genabel-commits] r857 - pkg/ProbABEL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Mar 18 20:09:33 CET 2012
Author: lckarssen
Date: 2012-03-18 20:09:33 +0100 (Sun, 18 Mar 2012)
New Revision: 857
Modified:
pkg/ProbABEL/src/data.h
Log:
Replaced some more fscanf()'s from ProbABEL's data.h. This time in function Nmeasured(char * fname, ...) and replaced them with fstream code.
This removes the last compiler warnings on fscanf's. ProbABEL (at least palinear and palogist) now compile without warnings.
Modified: pkg/ProbABEL/src/data.h
===================================================================
--- pkg/ProbABEL/src/data.h 2012-03-18 18:33:15 UTC (rev 856)
+++ pkg/ProbABEL/src/data.h 2012-03-18 19:09:33 UTC (rev 857)
@@ -33,33 +33,34 @@
int ncov = nphenocols - 2;
int nids_all = npeople;
- FILE * infile;
// first pass -- find unmeasured people
- if ((infile=fopen(fname,"r"))==NULL) {
- fprintf(stderr,"Nmeasured: cannot open file %s\n",fname);
+ std::ifstream infile(fname);
+ if (!infile)
+ {
+ std::cerr << "Nmeasured: cannot open file " << fname << endl;
}
+
char tmp[100];
- for (int i=0;i<nphenocols;i++)
+ for (int i=0; i<nphenocols; i++)
{
- fscanf(infile,"%s", tmp);
- // printf("%s ",tmp);
- } //printf("\n");
+ infile >> tmp;
+ }
unsigned short int * allmeasured = new unsigned short int [npeople];
int nids = 0;
for (int i = 0;i<npeople;i++)
{
allmeasured[i] = 1;
- fscanf(infile,"%s", tmp);
- for (int j=1;j<nphenocols;j++)
+ infile >> tmp;
+ for (int j=1; j<nphenocols; j++)
{
- fscanf(infile,"%s", tmp);
+ infile >> tmp;
if (tmp[0]=='N' || tmp[0]=='n') allmeasured[i]=0;
}
if (allmeasured[i]==1) nids++;
}
- fclose(infile);
+ infile.close();
delete [] allmeasured;
More information about the Genabel-commits
mailing list