The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway. © Copyright 2008
Here is the answer to one question the interviewer gave me:
#include <iostream.h> using namespace std; // toLower char *toLower(char *ptr); int main() { char *test = new char[251]; cout << "Enter a string to lower : "; cin.getline(test, 250); toLower(test); cout << "The result is : " << test << endl; } char *toLower(char *ptr) { while (*ptr != '\0') { if (*ptr > 'A' && *ptr < 'Z') { *ptr -= 'A' - 'a'; } *ptr++; } return ptr; }
Be the first to rate this post