00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00029 #include "adder.h"
00030
00031 LOCAL_D CConsoleBase* console;
00032
00033 LOCAL_C void DoStartL();
00034 LOCAL_C void CallExampleL();
00035
00036 LOCAL_C void DoStartL()
00037 {
00038
00039 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
00040 CleanupStack::PushL(scheduler);
00041 CActiveScheduler::Install(scheduler);
00042
00043
00044 CLongNumber* number = CLongNumber::NewL(console);
00045 CleanupStack::PushL(number);
00046
00047
00048 _LIT(KTextEnterNumber,"Singly linked list example.\nEnter the digits of a number...\n");
00049 console->Printf(KTextEnterNumber);
00050
00051 number->ReadNumber();
00052
00053
00054 CActiveScheduler::Start();
00055
00056
00057 CAdder* adder = CAdder::NewL(number);
00058
00059 _LIT(KTextSum,"Sum of all digits of the number : %d\n");
00060 console->Printf(KTextSum,adder->Add());
00061 delete adder;
00062
00063
00064 CleanupStack::PopAndDestroy(2,scheduler);
00065 }
00066
00067 GLDEF_C TInt E32Main()
00068 {
00069 __UHEAP_MARK;
00070 CTrapCleanup* cleanup=CTrapCleanup::New();
00071 TRAPD(error, CallExampleL());
00072 delete cleanup;
00073 __ASSERT_ALWAYS(!error, User::Panic(KTxtEPOC32EX, error));
00074 __UHEAP_MARKEND;
00075 return 0;
00076 }
00077
00078 LOCAL_C void CallExampleL()
00079 {
00080 console=Console::NewL(KTxtExampleCode, TSize(KConsFullScreen, KConsFullScreen));
00081 CleanupStack::PushL(console);
00082 TRAPD(error, DoStartL());
00083 if (error)
00084 console->Printf(KFormatFailed, error);
00085 else
00086 console->Printf(KTxtOK);
00087 console->Printf(KTextPressAnyKey);
00088 console->Getch();
00089 CleanupStack::PopAndDestroy();
00090 }