Results 1 to 8 of 8

Thread: Printing text without using printf()

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Printing text without using printf()

    Is it possible to print text without using the printf().If yes can someone please post the code along with meaning's.Thanks in advance.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Printing text without using printf()

    In C, puts() or putc(). You could also use fprintf() and pass stdout as the file handle.
    In C++, cout.

    Look them up, they're simple.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Printing text without using printf()

    which C/C++ compiler are you using?
    Show Appreciation. Rate Posts.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: Printing text without using printf()

    Quote Originally Posted by Harsh Gupta
    which C/C++ compiler are you using?
    ok,I will try to modify my question

    Is it possible to print text

    without using printf() in C

    without using cout in C++

  5. #5
    Addicted Member SpS's Avatar
    Join Date
    Jul 2005
    Posts
    201

    Re: Printing text without using printf()

    look hard...answer is already given for C
    In case of C++, use cerr though we don't use for this purpose but by default, cerr is same as cout
    #Appreciate others by rating good posts !!

    #The Software Peter Principle is in operation when unwise developers "improve" and "generalize" the software until they themselves can no longer understand it, then the project slowly dies.

    #People who are still ignorant of their ignorance are dangerous.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: Printing text without using printf()

    Quote Originally Posted by sunnypalsingh
    look hard...answer is already given for C
    In case of C++, use cerr though we don't use for this purpose but by default, cerr is same as cout
    sorry I knew that the answer was out for C.But can we print numbers using putc() or puts().

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Printing text without using printf()

    Yes, but you have to convert them manually first. And the standard C way of converting a number to a string is sprintf (snprintf in C99); in C++ it's a stringstream.

    May I ask why you want to know?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: Printing text without using printf()

    Quote Originally Posted by CornedBee
    Yes, but you have to convert them manually first. And the standard C way of converting a number to a string is sprintf (snprintf in C99); in C++ it's a stringstream.

    May I ask why you want to know?
    Im sorry that I didnt tell earlier.Im a 3rd year Engineering Student preparing for my campus interview,so Im trying to learn some of the stuff they ask and the answers for them.

Posting Permissions

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



Click Here to Expand Forum to Full Width