Why not just separate these tasks into separate functions?
Printable View
Why not just separate these tasks into separate functions?
no you don't... you can do that from deep within main or from right in main if you really think about it... but starting from main again is NOT the way to do it...
for example:
Code:int main()
{
char*classname=new char[120];
int classnum;
for(;;)
{
cout<<"Enter the class name: ";
cin.getline(classname,120,'\n');
cout<<"Enter the class number: ";
cin>>classnum;
//don't forget some way to exit the program eventually...
createclass(classname,classnum);
checkclasses();
}
delete[]classname;
return 0;
}
I did.Quote:
Originally Posted by Kybo_Ren
I figured there was an easier way to do it. I'll go do some reasearch and look into that, thanks *adds rep*Quote:
no you don't... you can do that from deep within main or from right in main if you really think about it... but starting from main again is NOT the way to do it...
What I meant was why not just put what you're doing in main in a different function, then in main() call that function. That way you can call it however many times you want.
Thanks major_small, that will help me ALOT.
>but I'm wondering if there's actually a clause in the standard that says that you can't do that...
"The function main shall not be used within a program." from section 3.6.1 seems to cover it pretty well.