×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    18

    Printing Integer to the console

    Hi ,
    I have created a Symbian console Application i want to write integer to console how can i do it???

    for printing the string i am using
    now i need to print integer which i have stored in some variable
    console->Write(_L("Hello, world!\n"));

  2. #2
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: Printing Integer to the console

    console->Write(_L("Hello, world! %d \n"), yourVariable);

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    18

    Re: Printing Integer to the console

    I tried printing it using
    console->Write(_L("Hello, world! %d \n"), info->build);
    but it gives the error as
    error: no matching function for call to `CConsoleBase::Write(TPtrC, SHI_UInt32&)'

  4. #4
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: Printing Integer to the console

    Sorry - you need to put the integer in a descriptor and then print the descriptor to the console.

    Something like

    TBuf<8> temp;
    temp.Num(yourVariable);
    console->Write(temp);

  5. #5
    Registered User
    Join Date
    Jul 2007
    Location
    Noida
    Posts
    1,503

    Re: Printing Integer to the console

    Quote Originally Posted by coolbunty View Post
    Hi ,
    I have created a Symbian console Application i want to write integer to console how can i do it???

    for printing the string i am using
    now i need to print integer which i have stored in some variable
    console->Write(_L("Hello, world!\n"));

    Use this, i hope this will help u.


    Code:
    _LIT(KTxtExampleCode,"Symbian OS Example Code");
    
    LOCAL_D CConsoleBase* console; // write all your messages to this
    
    void outputbool(int b)
    {
    	console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
    	CleanupStack::PushL(console);
    	if(b)
    	{
    		console->Printf(_L("TRUE"));
    	}
    	else
    	{
    		console->Printf(_L("FALSE"));
    	}
    	console->Getch(); // get and ignore character
    	CleanupStack::PopAndDestroy(); // close console	
    }
    
    
    void print_int(int d)
    {
    	console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
    	CleanupStack::PushL(console);
    	console->Printf(_L("%d"),d);
    	console->Getch(); // get and ignore character
    	CleanupStack::PopAndDestroy(); // close console
    }
    
    //Call this
    
    print_int(1);
    Regards,
    Amit


    ****"Putting a Smile on other's faces is the essence of true Happiness"****

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Printing Integer to the console

    Quote Originally Posted by coolbunty View Post
    I tried printing it using
    console->Write(_L("Hello, world! %d \n"), info->build);
    but it gives the error as
    error: no matching function for call to `CConsoleBase::Write(TPtrC, SHI_UInt32&)'
    what is the type of info->build as above write formater requires a Int

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    18

    Smile Re: Printing Integer to the console

    Hey Thanks it worked , it has put smile on my face

  8. #8
    Registered User
    Join Date
    Jun 2013
    Posts
    12

    Re: Printing Integer to the console

    If i have a Button Event CallSoftKeyPressedL(). I want to print the value of aCommand which is signed integer type.

    TBool CMobileDialerContainerView::CallSoftKeyPressedL( TInt aCommand )

    i have written the line to print the value of aCommand
    console->Printf(_L("%d"), aCommand);
    But it is giving me the error that console undeclared, First use this function. How should i print the value of aCommand

  9. #9
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: Printing Integer to the console

    Hello,
    you could try log on file instead, here is a first starting point:
    http://developer.nokia.com/Community...ebug_log_files
    or, if you are using carbide, its debugging tools (and also on device debugging or ODD if you have a real phone)

    br,
    pg

  10. #10
    Registered User
    Join Date
    Jun 2013
    Posts
    12

    Re: Printing Integer to the console

    Hi Pavarang,
    Yes i am using Carbide. Can you tell me the line of code so that i can print the wanted value??? i am using E72..

  11. #11
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: Printing Integer to the console

    Quote Originally Posted by vikaskumar2020 View Post
    Hi Pavarang,
    Yes i am using Carbide. Can you tell me the line of code so that i can print the wanted value??? i am using E72..
    Hi :-)
    The article of above link is about 5 lines of description and just some more of code to copy, paste and try... you could copy, paste and try it and if it doesn't work ask for more help :-)

    all the best
    pg

Similar Threads

  1. Dial a Call Console Problem
    By Ceratos in forum Symbian
    Replies: 4
    Last Post: 2008-07-18, 09:48
  2. Sensor API within console application
    By Saxer in forum Symbian
    Replies: 3
    Last Post: 2008-07-16, 13:38
  3. Printing Debug messages on Console
    By prabhupingili in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2007-11-26, 13:49
  4. Replies: 5
    Last Post: 2006-08-02, 12:35
  5. Printing to console on 3650
    By earamsey in forum Mobile Java General
    Replies: 0
    Last Post: 2004-04-17, 18:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×