Encrypt the English alphabet and keep punctuation marks

#include <stdio.h>
#include <stdlib.h>
void main()
{
	char *s=NULL;
	char str[50];
	int i;
	printf("输入英文字符串(不超过50个字符,按回车键结束输入):");
	
	for(i=0;i<50;i++)
	{
		scanf("%c",&str[i]);
		if(str[i]=='\n')//判断是否结束输入
		{
		 str[i]='\0';//为字符串添加结束符 
		 break; 
		
		}
	}
	
	s=str;
	while(*s!='\0')
	{
		if((*s>='a'&&*s<='z')||(*s>='A'&&*s<='Z'))
		*s=*s+4;
		s=s+1;
	}
	s=str;
	printf("%s",s);
} 

operation result
Insert picture description here

Published 11 original articles · Likes0 · Visits1

Guess you like

Origin blog.csdn.net/qq_38272075/article/details/105527873