// Template for Palindrome #include // We don't know in advance how many characters will be in the input // file, nor can C++ determine it automatically for us. // // That's why we make the array big enough to contain the // largest possible input. Actually, we need to make it one bigger // than the largest possible input. I won't explain here, but you // can take a look at https://www.learncpp.com/cpp-tutorial/c-style-strings/ // if you're curious. char line[100001]; int N; int main() { FILE* inputFile = fopen("palin.txt", "r"); FILE* outputFile = fopen("palout.txt", "w"); // Read the input. // Notice that unlike with reading integers, we don't have an // ampersand (&) before "line". // // Notice that although N and the string are on different lines, // we still only separate them by a space in the format string ("%d %s"). // This is because a space in the format string actually means "any number // of whitespace characters" (which includes spaces, tabs and newlines). fscanf(inputFile, "%d %s", &N, line); for(int i = 0; i < N; i++) { // TODO: Replace this with a proper solution line[i] = '?'; } fprintf(outputFile, "%s\n", line); fclose(inputFile); fclose(outputFile); }