Home Segments Index Top Previous Next

740: Mainline

Now, fprintf can write out a request for information that is to be supplied to the server, and a call to fscanf can read in information that subsequently is supplied by the server. Note that the client's request originates with information supplied via the keyboard:

while (1) { 
  double keyed_number, received_number; 
  printf ("Please type an interest rate:\n> "); 
  scanf ("%lf", &keyed_number); 
  fprintf (to_server, "%f\n", keyed_number); 
  fflush (to_server); 
  fscanf (fm_server, "%lf", &received_number); 
  printf ("Server returned doubling time of %.1f years\n",