Creating an array of a type depending on runtime
<p>... is what I want to do. I have the following code:</p>

<pre><code>... 
    int len = 0; 
    char c; 
    bool fp = false;

    while (infile.good()) {
            c = infile.get();
            if (c == '\n') ++len;
            else if (c == '.') fp = true;
    }  

    if (fp == true){
            float Ai[N];
            float *Ao = new float [len];
    } else {
            int Ai[N];
            int *Ao = new int [len];
    }  

    for (int i=0; i&lt;L; ++i){
            for (int j=0; j&lt;N; ++j) infile &gt;&gt; Ai[j];
            Ao[i] = findmax(Ai);
    }
...
</code></pre>

<p>It is supposed to make the array out of doubles if a decimal point is detected in the file or, if not, out of integers.</p>

<p>I didn't check the first loop yet because I didn't get it to compile:</p>

<pre><code>warning: unused variable ‘Ai’                                                         
warning: unused variable ‘Ao’
warning: unused variable ‘Ai’
warning: unused variable ‘Ao’
error: ‘Ai’ was not declared in this scope
error: ‘Ao’ was not declared in this scope
</code></pre>

<p>I suppose I have a fundamental problem with how to deal with this task and not just a simple error.</p>

<p>So, what is wrong and how to fix/make it right from the beginning?</p>
