program to use the getwords function to make it easy to take the word ``check'' or ``deposit'', and the amount, from a single line.



#include
#include /* for atof() */

#define MAXLINE 100
#define MAXWORDS 10

extern int getline(char [], int);
extern int getwords(char *, char *[], int);

int main()
{
double balance = 0.0;
char line[MAXLINE];
char *words[MAXWORDS];
int nwords;

while (getline(line, MAXLINE) > 0)
{
nwords = getwords(line, words, MAXWORDS);

if(nwords == 0) /* blank line */
continue;

if(strcmp(words[0], "deposit") == 0)
{
if(nwords <>

No comments:

Post a Comment