1

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?

  • 3
    What is he supposed to be teaching? If he's trying to teach the C language, that's one thing. If he's trying to teach Windows console I/O, that's something else. – David Schwartz Jan 16 '14 at 11:02
  • 2
    `gotoxy`is not in any standard C headers: http://stackoverflow.com/questions/9782287/undefined-reference-to-gotoxy-in-c -- is this one of the "still using Turbo C, and proud of it" dinosaurs? – Jongware Jan 16 '14 at 11:49

2 Answers2

3

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");.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278
  • So, would you consider this objectively wrong? I'm thinking of asking the professor and confronting him of the matter. I feel that he's teaching a lot of wrong things... – Matthew Valdez Jan 16 '14 at 11:06
  • 2
    I would consider it objectively wrong to use a specialized, platform-specific function when a simple, standard method exists. – David Schwartz Jan 16 '14 at 11:07
2

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()

Prarthana Hegde
  • 361
  • 2
  • 7
  • 18