Matthew Valdez
Matthew Valdez

Reputation: 11

Using gotoxy for newline?

My professor uses gotoxy for newlines. For example:

#include <stdio.h>
#include <conio.h>

main()
{
   gotoxy(0, 1);

   printf("Hello World");

   gotoxy(0, 2);

   printf("This is app");

   return 0;
}

I'm very troubled why he is doing this. It's incredibly verbose, it's non-standard, and introduces overhead. I think this is better:

   printf("Hello World \n");

   printf("This is app \n");

   return 0;

Am I missing something? Should I confront him about the matter?

Upvotes: 1

Views: 353

Answers (2)

Prarthana Hegde
Prarthana Hegde

Reputation: 361

Using \n is the simples and best way to do it. If you want two lines of gap, you can use \n \n and so on. I think you should clarify the reason behind him using gotoxy()

Upvotes: 2

David Schwartz
David Schwartz

Reputation: 182779

You are missing one very important thing -- gotoxy only works on the console. Gratuitously making your programs unable to be redirected and non-standard is idiotic. This is on the same level of silliness as system("pause");.

Upvotes: 3

Related Questions