This is a simple casear cipher encode only portion that i wrote. it:
1. Promtps for user input
2. Asks for the shift value
3. Uses the shift value such as 2 on the first letter then increments it by 1 for each letter after that.
EXAMPLE: Hello would be Jhpqu
My problem is at the end of each encrypted word it prints a funny character that i dont need. How can i eliminate it??thanks
Code:#include <stdio.h> #include <string.h> /*encode function, to encode user input */ int main() { char buff[BUFSIZ]; int i = 0; int shift_value; int p = 0; printf( "**initializing.....**\n\n" "**linking..........**\n\n"); printf( "Welcome agent Brown\n\n"); printf( "You have accessed the Caesar Cipher program\n\n"); printf("\nPlease enter the text you wish to encrypt: ");/*accept user input */ fgets(buff, sizeof(buff), stdin); printf("\nEnter your encryption shift value (anything from +-1 to 25): "); scanf ("%i", &shift_value); { while ( buff[i] != '\0' ) { buff[i] = buff[i] + shift_value + i++; } } printf("\n Your encrypted text is:%s\n",buff);/*return encrypted text */ return 0; /* indicate successful completeion */ }



LinkBack URL
About LinkBacks



