// file: lecture_12/example.cc // // local include files // #include "example.h" // method: main // // main program starts here // int main(int argc, char** argv) { // declare a character string // // char str2[] = "Alex"; // fprintf(stdout, "str2 = %s [%u] [%p]\n", str2, str2, str2); // char str[4]; str[0]='A';str[1]='l';str[2]='e';str[3]='x'; /* fprintf(stdout, "str[0] = %c (%d)\n", str[0], str[0]); fprintf(stdout, "str[1] = %c (%d)\n", str[1], str[1]); fprintf(stdout, "str[2] = %c (%d)\n", str[2], str[2]); fprintf(stdout, "str[3] = %c (%d)\n", str[3], str[3]); // fprintf(stdout, "str[4] = %c (%d)\n", str[4], str[4]); */ // note that argv[1] is a character string // // fprintf(stdout, "argv[1] = %s (%p)\n", argv[1], argv[1]); char** x = argv; fprintf(stdout, "x = %p (%u), argv = %p (%u)\n", x, x, argv[1], argv[1]); // float pointer // float x = (float)0.0; float* vvv; float* v = new float[3]; fprint(stdout, "v[0] = %f\n", v[0]); // exit gracefully // exit(0); } bool myfunct(float* x) { float* joe = new float[10]; *x = 99.0; // changes the value of x in the calling program because it is a pointer return true; }