All pastes #809998 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-09 13:13 UTC
rendered paste body
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, char * argv[])
{
    ifstream fin;
	//fin.open(argv[2]);                                      // Take input file from argument
	fin.open("example.txt");

	char charlist[256];                                    // Make a table to store different characters.
	int list_length;                                        // Charlist length.
    if(fin.fail())                                          // Was the input file valid?
    {
        cout << "Failed to open input file.";
    }
    else
    {
                int i=1;                               // counter for storing distinct characters in charlist;
                while(!fin.eof())
                {
                    char next= fin.get();                 // Store next character in variable next;
                    bool ok = true;
                    for(int j=1;j++;j<=i)
                    {
                        if (charlist[j] == next)
                        {
                            ok = false;
                        }
                    }
                    if(ok == true)
                    {
                        i++;
                        charlist[i] = next;
                    }
                }
                list_length = i;
                cout << "\n\n\n";
                cout << "Success.\n";
                cout << "Charlist is: \n";
                for(int i=1;i++;i<=list_length)
                { cout << charlist[i]; }
                int example;
                cin >> example;
    }
}