-
Code Check
Why won't this work? the compiler says the function is wrong. It's a program that finds ASCII values. pretty straightforward.
Code:
*/
#include <iostream.h>
#include <conio.h>
int main()
{
void calc()
{
int i;
int max;
cin>>max;
for(i=1;i<max;i++)
{
char value=i;
cout<<value<<endl;
}
}
char option;
cout<<"Continue? c=yes"<<endl;
cin>>option;
if(option=='c')
{
calc();
}
getch();
getch();
getch();
return 0;
}
-
Did it say anything about local function definitions being illegal? :D
You have to move it outside of main().
Oh, and it's <iostream>, not <iostream.h> (you'll need a using namespace std; in there after the includes).
-
What compiler? I suggest you change it for one that's actually compliant with the language specification ;)
-
It doesn't need .h??? I have always needed that in my programs... I'm using Microsoft c++. Why is the .h not needed, and what difference will it make in a program?
-
In VC++ 5 and above (what I had), you had support for the newer version of the iostreams library, which is in the header without the .h, matching the rest of the standard library; i.e. <vector>, <list>, <string>, <iostream>, etc.
The .h versions of the streams are deprecated (in fact VC++7 gives you a warning about this if you try and use them).
-
The new headers basically have no change in the interface to the user, but are implemented in a better and more generic way. They also provide a few new features and basically work together better.