Hi i am having problem with strings using for loop. When i enter input abc, strlen shows that string length is 3 but when i enter abc d string length still shows 3 and i think loop stop when it sees space.
here is my program
Thanks for your helpCode:/* Caesar Cipher
Darshan
*/
#include <stdio.h>
#include <string.h>
int main(){
// Message to be encrypted
char input[80];
// shift
int key =0;
int i;
// Enter shift amount
printf("Enter shift amount (1-25): ");
scanf("%d", &key);
// enter message
printf("Enter message to be encrypted: ");
scanf("%s", &input);
for(i=0; input[i] != '\0';i++)
{
// check if letter is captial or lower case
if (input[i]>='A' && input[i]<='Z')
{
input[i] = (input[i] - 'A' + key) % 26 + 'A';
}
else
if (input[i]>='a' && input[i]<='z')
{
input[i] = (input[i] - 'a' + key) % 26 + 'a';
}
}
printf("\nEncrypted message: %s", input);
printf("\nstrlen(%lu)", strlen(input));
getchar();
getchar();
return 0;
}