0

the codes below represent output of coordinates,for example it'll show faces_x=201 etc. However,they are all displayed vertically. How to print them on the console horizontally?

printf("faces_x=%d\n", faces[i].x); printf("faces_y=%d\n", faces[i].y); 
3
  • 3
    Remove the \ns? Commented May 4, 2020 at 16:07
  • 1
    Alternative: std::cout << "faces_x=" << faces[i].x << " faces_y=" << faces[i].y; Some delimiter, a space or a newline most likely, may be needed on the end to distinguish one set of data from the next. Commented May 4, 2020 at 16:15
  • thanks for the constructive inputs, it helped me alot. thanks guys Commented May 5, 2020 at 19:42

1 Answer 1

1

If you simply remove the newlines, i.e. \n, the 2 lines will be printed horizontally:

printf("faces_x=%d", faces[i].x); printf("faces_y=%d", faces[i].y); 

Note that your question doesn't actually need the second \n to be removed, unless you want the following output to start on a new line.

Sign up to request clarification or add additional context in comments.

1 Comment

sorry for a simple question as im not really good at this, you are a life saviour.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.