Reading using fstream character by character and passing the fstream to a function for further reading?
<p>Ok so I'm trying to open a file for reading and I want to read the first character only then depending on what that character is I send it to a given function. For example if it is a number, I send it to a function that continues reading to see if its just an int or a float.
I cant seem to figure out how to do this </p>

<pre><code>void dummy(char dum, std::ifstream&amp; fin){
    char test = dum;
    fin&gt;&gt;test;
    string simple = simple + test;
    simple = simple + test;
    ofstream outFile;
    outFile.open("output.txt");
    outFile&lt;&lt;simple&lt;&lt;"\n";
    return;
}


int main(int argc, char *argv[]){
    char c;
    //ifstream readFile;
    /*if(argc &gt;= 1){
    readFile.open(argv[1]);
    }*/
    ifstream readFile;
    readFile.open("input.txt");
    readFile.unsetf(ios_base::skipws);
    readFile&gt;&gt;c;
    while(!readFile.eof())
    {   
        switch(c){
        case 'a':
            dummy(a,readFile);
        }
    }
}
</code></pre>

<p>it keeps throwing this error: Microsoft C++ exception: std::bad_alloc at memory location (location). Any help is greatly appreciated. </p>
