![]() |
ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
|
Source file for the small program Unique. More...
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. |
Source file for the small program Unique.
The purpose of the Unique program is to remove identical lines in a list.
Definition in file Unique.cpp.
int main | ( | int | argc, |
char * | argv[] | ||
) |
The main method of the program.
Main function in this short program.
argc | argc, standard. |
argv | argv, 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; }