using stdout

This is a discussion on using stdout within the C Programming forums, part of the General Programming Boards category; hello everybody i would like to know how to use stdout to print the result of a function this is ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    4

    using stdout

    hello everybody

    i would like to know how to use stdout to print the result of a function

    this is what i have

    char input[51];
    fgets(input,51,stdin);

    stdout -> I don't know how to use it

    Code:
    void function() {
    printf("result") }
    i just can do it with printf

    thanks

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    143
    You can use:
    Code:
    printf("result\n");
    fprintf(stdout, "result\n");
    puts("result");
    fputs("result", stdout);
    obviously the printf functions are useful if you want formatting etc.
    notice that puts automatically adds a new line.
    The functions taking file pointers (eg stdout) can be useful if you sometimes want to write to a file rather than stdout.
    DavT
    -----------------------------------------------

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    do you mean...
    Code:
    int main(void)
    {
      char input[51];
      fgets(input,51,stdin);
    
      printf("Result: %s",input);
      //fprintf(stdout,"Result: %s",input);
      return 0;
    }
    sorry if i misunderstood your question

  4. #4
    C maniac
    Join Date
    Aug 2004
    Location
    Cyberwarping to Middle Earth
    Posts
    154

    Wink

    Try reading Sams Teach Yourself C++ in 21 Days,
    or C++: The Complete Reference. Or any starting book.

    If that dosen't help, here's your answer:

    Code:
    void func() {
    	cout << "result";
    }
    Keep programming!

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Quote Originally Posted by kawk
    Code:
    void func() {
    	cout << "result";
    }
    - C board
    - C, not C++
    - therefore stdout, not cout or std::cout

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Case Statement
    By danlee58 in forum C Programming
    Replies: 16
    Last Post: 11-23-2008, 08:46 PM
  2. Replies: 2
    Last Post: 07-12-2008, 01:00 PM
  3. stdout with JNI
    By GoLuM83 in forum C Programming
    Replies: 4
    Last Post: 12-14-2006, 01:27 PM
  4. forcing stdout of external program to be line-buffered
    By FreakCERS in forum C Programming
    Replies: 4
    Last Post: 09-17-2006, 01:46 PM
  5. Problems with switch()
    By duvernais28 in forum C Programming
    Replies: 13
    Last Post: 01-28-2005, 10:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21