Main Content

Remember to ask the question before you listen for the answer

Archive - Originally posted on "The Horse's Mouth" - 2016-01-26 21:38:21 - Graham Ellis

I love some of the basics ... like reminding people writing programs that they need to prompt the user to make an input at the keyboard before they read that input - otherwise they'll get people complaining that the program just hangs. In C, from today's course.

  /* Tell the user that you want input before reading from keyboard! */
      printf("How many carriages on the train today? ");
  /* Read a value into length */
      scanf("%d",&length);

Complete example - [here]. C and C++ courses - [here].