Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- /*int palindrome(FILE &pfp, char *input)
- {
- return 0;
- }
- int cipher(FILE &cfp, char *input)
- {
- return 0;
- }
- */
- int main (void)
- {
- FILE* ifp = fopen("input.txt", "r");
- FILE* pfp = fopen("palindromes.txt", "w");
- FILE* cfp = fopen("cipher.txt", "w");
- char input[32] = {0};
- char inputCopy[32] = {0};
- (fscanf(ifp, "%s", input));
- printf(input);
- printf("\n");
- while (fscanf(ifp, "%s", (input)) != EOF) {
- printf("work \n");
- //palindrome section start
- printf(input);
- unsigned int palindromeLength = (unsigned int) (strlen( input )/2);
- char front[palindromeLength + 1];
- char back[palindromeLength + 1];
- memcpy( front, input, palindromeLength);
- strcpy(inputCopy, input);
- strrev(inputCopy);
- memcpy( back, inputCopy, palindromeLength);
- if (strcmp(front, back) == 1){
- fprintf(pfp, "%s", input);
- };
- //cipher section start
- strcpy(inputCopy, input);
- for (int i = 0; i < (char) (strlen(inputCopy)); i++){
- inputCopy[i] = (char) (inputCopy[i] + 13);
- if (inputCopy[i] > 'z') {
- inputCopy[i] = (char) (inputCopy[i] - 26);
- }
- }
- fprintf(cfp, "%s", inputCopy);
- }
- fclose(ifp);
- fclose(pfp);
- fclose(cfp);
- printf("done \n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement