// this program is buggy #include #include const int bufSize = 20; int main(int argc, char** argv) { using namespace std; if (argc < 3) { cerr << "need a char and a word as arguments on cmd line" << endl; return 1; } // we define a test integer with value 1 int testInt = 1; // get the first char of the first arg on cmd line char theChar = argv[1][0]; // get the second argument as word char buffer[bufSize]; strncpy(buffer, argv[2], bufSize); char* wordPtr = buffer; // skip chars in word and delete them until finding theChar while(*wordPtr != theChar) { *wordPtr = ' '; wordPtr++; cout << (int) (wordPtr - buffer) << endl; } // now see what value has testInt cout << testInt << endl; return 0; }