• Please send your homework (ZIP or RAR file) to TA at cs101-ta@voip.edu.tw
  • Deadline:2008/1/4 11:00 AM
    • Subject of email: [CS101 HW14] 91234567
    • Create New Project
      • Choose Project types and Templates
      • Name:
        • HW14_1_91234567
        • HW14_2_91234567
      • Compress the folder to a ZIP or RAR file
        • Filename: project name
  • HW14_1

    (From: Exercise 1 on P.321)
    Consider the following function:
        int ascVal(size_t i, const char* p)
    {
    // print the ASCII value of the char
    if (!p || i > strlen(p))
    return -1;
    else
    return p[i];
    }
    Write a program that will call this function through a pointer and verify that it works. You'll need an #include directive for the <cstring> header in your program to use the strlen() function.
  • HW14_2

    (From: Exercise 2 on P.322)
    Write a family of overloaded functions called equal(), which take two arguments of the same type, returning 1 if the arguments are equal, and 0 otherwise. Provide versions having char, int, double, and char* arguments. (Use the strcmp() function from the runtime library to test for equality of strings. If you don't know how to use strcmp(), search for it in the online help. You'll need an #include directive for the <cstring> header file in your program.) Write test code to verify that the correct versions are called.