|
|
User login
Feeds |
Printing to a console
|
|||||
| Fri, 2005-07-22 10:42 | |
|
Hi !
I am new to Symbian C++ and need help with printing a descriptor(string) to a console. Consider the code below where I print a descriptor on the console. Code: TBufC <20> Kbuf = "hello" ; TInt ctr = 0 , len ; TText ch ; len = KBuf.Length();   do   {       ch = KBuf[ctr];            _LIT(Kch,"%c");            console->Printf(Kch,ch);            ctr++ ;   }while(ctr < len);   In the above case I am printing a string (Descriptor) to the console character by character. Isnt there a way or some function using which I can print the descriptor directly without using the character by character approach ?. In ANSI C++ e.g. there is a puts() function but there doesnt seem to be a console->Puts() counterpart in Symbian C++. Plz help. |
|
Forum posts: 12
TInt myNumber = 0;
console->Printf(_L("My number: %d"), myNumber);
Forum posts: 52
Thanks for replyingÂ
TBuf <20> test ;
_LIT(KTest,"hello");
test = KTest ;
console->Printf(_L("%s"),test);
The above doesnt work !!.
Forum posts: 226
_LIT(KTest,"hello");
TBuf <20> test(KTest) ;
console->Printf(test);
Or.......
console->Printf(_L("hello"));
Or.........
_LIT(KTest,"hello");
console->Printf(KTest);
BR,
Forum posts: 52
void CDesc::Greet()
{
 //Ask for users name
  console->Printf(_L("\nEnter your name :"));
 //Declare a buffer on the stack to hold the name
 TBuf <100> name ;
 TText ch ; //User entered character
 TInt ctr = 0 , asc ;
 //Receive the name
 do
 {
   ch = console->Getch() ;
   asc = ch ;
   console->Printf(_L("%c"),ch);
   if(asc != 32 && asc != 13)
      name.Append(ch);
   ctr++ ;
 }while(asc != 32 && asc != 13) ; //Space = 32 , Enter = 13
  //Print a Hello on a newline
  console->Printf(_L("\nHello,")) ;
  //Print the name
 console->Printf(name);
 //Print an exclamation
  console->Printf(_L("!"));
}
Isd there a counterpart of scanf() in Symbian C++ that will allow me to receive a string from the user at one stretch rather than resorting to character by character logic ?.
Thanks