ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
Functions
Unique.cpp File Reference

Source file for the small program Unique. More...

#include "Unique.h"
#include <iostream>

Go to the source code of this file.

Functions

bool uniqueCompare (string first, string second)
bool uniqueSort (string first, string second)
int main (int argc, char *argv[])
 The main method of the program.

Detailed Description

Source file for the small program Unique.

Author:
Rikard Lundmark

Purpose

The purpose of the Unique program is to remove identical lines in a list.

Definition in file Unique.cpp.


Function Documentation

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

The main method of the program.

Main function in this short program.

Parameters:
argcargc, standard.
argvargv, standard.

Definition at line 28 of file Unique.cpp.

References NULL, proceed_interact(), proceed_nointeract(), and CommandLineInterpreter::readFlaggedCommand().

{
  if(argc!=3)
    {
      fprintf(stderr,"Usage: %s inputfile outputfile\n",argv[0]);
      return 0;
    }
  FILE * myFile;
  myFile = fopen(argv[1],"r");
  if(myFile==NULL)
    perror("File 1 could not be opened.\n");
  char line[100];
  list<string> myList;
  while (fgets(line,100,myFile)!=NULL)
    {
      string myString(line);
      myList.push_back(myString);
    }
  pclose(myFile);
  myList.sort(uniqueSort);
  myList.unique(uniqueCompare);
  myFile = fopen(argv[2],"w");
  if(myFile==NULL)
    perror("File 2 could not be opened.\n");
  for(list<string>::iterator it = myList.begin(); it!=myList.end(); it++)
    {
      fprintf(myFile, "%s", (*it).c_str());
    }
  pclose(myFile);
  return 0;
}
 All Classes Files Functions Variables Enumerations Enumerator Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark