this activity you will write a main function, an interface header file,
and a function implementing the header file interface, that
one line of data with three '$' terminated fields on it.
as necessary, the fields to an internal numeric format.
these values via reference parameters (e.g., pointers).
Your program will read exactly one line from standard input. The line will be formatted as follows (
you need not worry about any errors
is a single character.
is a string of characters representing a legal decimal integer.
is a string of characters reprsenting a double precision number.
is the literal dollar sign character.
All input lines may be assumed to be legal, and there are at most 25
characters in the strings for the integer and double precision number.
routine reads one line of data, consisting of three fields, and returns the values in the fields via reference parameters.
The calling sequence has three arguments:
- a pointer to a char variable.
- a pointer to an int variable.
- a pointer to a double precision variable.
1. Reads the three fields into local variables using
DO NOT USE
2. Converts the two numeric fields from ASCII strings to numbers:
a) Use atoi for the integer.
b) Use atof for the double.
3. Uses the parameter pointers to store the three values in variables
declared in the caller, and
Download the activity journal and c_pointers.zip file
Unpack the zip file in an empty working directory. You should see the following skeleton files:
The interface to the function that reads the three values on the line,
converts the two numeric strings to integer and double precision,
respectively, and returns the three values via argument pointers of the
appropriate type. The header file has the read_data function prototype that
you must update to match your modified function declaration.
The implementation of the read_data.h interface.
The driver program which declares the variables filled in by the read_data
function, calls the function with appropriate pointer arguments, and,
on return, prints the results. The format string to use is given in the
header comment of main.c.
complete this activity by filling in the three skeleton files above. The point is
to print a character, integer and double precision number, rather, it
is to give you experience using pointers to pass data into and out of a function.
You are also to create a
whose primary target is an executable program named
. This executable depends on the two object files, which in turn depend
on the approriate source files. Your instructor should be able to type
on Linux and get an executable file named
which meets the activities specification.
The directory in your repository for this activity is
Please place this directory in the root of your repository.