W
Wes
Hello,
I am trying to learn C from the book "C By Example". The first example
in the book is:
/* Filename: C2FIRST.C
Requests a name, prints the name 5 times, and rings a bell */
#include <stdio.h>
#define BELL '\a'
main()
{
int ctr=0; /* Integer variable to count through loop */
char fname[20]; /* Define character array to hold name */
printf("What is your first name?"); /* Prompt the user */
scanf(" %s", fname); /* Get the name from the
keyboard */
while (ctr < 5) /* Loop to print the name */
{ /* exactly 5 times */
printf("%s\n", fname);
ctr++;
}
printf("%c", BELL); /* Ring the terminals bell */
return;
}
The program compiles with no errors. During execution the name repeats
5 times but there is no BELL sound. Was this program possibly NOT
meant to run on a PC? The book is from 1994. I am using Windows ME
(yuck)
Thank you
I am trying to learn C from the book "C By Example". The first example
in the book is:
/* Filename: C2FIRST.C
Requests a name, prints the name 5 times, and rings a bell */
#include <stdio.h>
#define BELL '\a'
main()
{
int ctr=0; /* Integer variable to count through loop */
char fname[20]; /* Define character array to hold name */
printf("What is your first name?"); /* Prompt the user */
scanf(" %s", fname); /* Get the name from the
keyboard */
while (ctr < 5) /* Loop to print the name */
{ /* exactly 5 times */
printf("%s\n", fname);
ctr++;
}
printf("%c", BELL); /* Ring the terminals bell */
return;
}
The program compiles with no errors. During execution the name repeats
5 times but there is no BELL sound. Was this program possibly NOT
meant to run on a PC? The book is from 1994. I am using Windows ME
(yuck)
Thank you