Why not just separate these tasks into separate functions?
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; }
Last edited by major_small; 10-23-2004 at 06:55 PM.
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
I did.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*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...
To code is divine
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.
To code is divine
>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.
My best code is written with the delete key.