// file: lecture_19/myprog.cc // // local include files // #include "myprog.h" // main: myprog // // This is a driver program that does some very simple things. // int main(int argc, const char** argv) { /* // demonstrate using a library function // for (long i = 0; i < DEGREES; i++) { float val = (float)i / (float)DEGREES * (float)2.0 * M_PI; fprintf(stdout, "%d (%f): %f\n", i, val, sin(val)); } // demonstrate string processing // char str[] = "Joe"; fprintf(stdout, "the length of str (%s) = %d\n", str, strlen(str)); // open a file and read a line // FILE* fp = fopen(argv[1], "r"); char buf[999]; fgets(buf, 998, fp); fclose(fp); fprintf(stdout, "the value of buf is [%s]\n", buf); // strip the linefeed from buf? // buf[strlen(buf) - 1] = (char)NULL; fprintf(stdout, "the value of buf is [%s]\n", buf); // demonstrate strstr // char str[] = "Temple ECE 1111"; // char* ptr = strstr(str, (char*)argv[1]); char* ptr = strcasestr(str, (char*)argv[1]); fprintf(stdout, "found [%s] in [%s] at location [%s]\n", argv[1], str, ptr); */ // call mysum // fprintf(stdout, "%f + %f = %f\n", atof(argv[1]), atof(argv[2]), mysum(atof(argv[1]), atof(argv[2]))); // exit gracefully // return(0); }