C Language Q & A # 10 (cont.)
- Example:
printf(“Enter the number of widgets produced:\n”);
fprintf(stdprn, “Enter the number of widgets produced:\n\r”);
scanf(“%d”, &numWidgets);
printf(“You entered %d widgets.\n”);
fprintf(stdprn,“You entered %d widgets.\n\r”);
- The additional stdprn tells fprintf to send characters to the “standard printer”.
- C has some peccadilloes in handling the newline concept with DOS. DOS really wants to see two characters (a line feed, and a carriage return) to move the cursor to the start of the new line. C treats this same concept as a single “newline” character (‘\n’), and usually handles the translation into DOS without too much effort.