Thread: printf in C++

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    159

    printf in C++

    Hi,
    I am changing to work in C++ from C. In my C++ code, I have a line like this
    Code:
      printf("%d %d %d %d \n", x0,y0,x1,y1);
    There is nothing printed out on the console. If I call cout next, then I can get the output of both
    Code:
      printf("%d %d %d %d\n", x0,y0,x1,y1);
      cout<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<endl;
    It is like cout push printf to do what it is supposed to. Any idea how to correctly use printf in C++? Thanks!

    Update:
    There was mistake in my first post.
    with "\n" printf works, while without "\n" it doesn't.
    Just out of curiosity, why the latter happens?
    Last edited by lehe; 02-05-2009 at 11:32 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. segmentation fault upon reload
    By yabud in forum C Programming
    Replies: 8
    Last Post: 12-18-2006, 06:54 AM
  4. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 09:23 AM
  5. Drawing tables in C
    By stanoman in forum C Programming
    Replies: 5
    Last Post: 10-09-2003, 10:14 AM