⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 up2low.cpp

📁 用来小写转换为大写的小程序
💻 CPP
字号:
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>

char xx[200][200] ;
int maxline = 0 ;  /* 文章的总行数 */

int ReadDat(void) ;
void WriteDat(void) ;

void upOrlow(void)
{
int i;
//int j,k;
//char word[21];
char *p;
//char str[80];
for(i=0;i<maxline;i++)
{
//	memset(str,0,80);
	p=xx[i];
//	j=0;
//	k=0;
//	memset(word,0,21);
	while(*p)
	{
//	 if(isalpha(*p))
//	 {
//		 word[j++]=*p++;
//		 if(*p)
//			 continue;
//	 }
	 if(isupper(*p))
	 {
		 *p=tolower(*p);
		 p=p++;
	 }
	 else 
		 p=p++;
//   if(strlen(word))
//	    k++;
//   if(!(strlen(word)%2))
//		 strcat(str,word);
//	 j=0;
//	 memset(word,0,21);
//	 while(*p && !(isalpha(*p)))
//	 p++;
	}
//	strcpy(xx[i],str);

}




}

void main()
{
  /*clrscr() ;*/
  if(ReadDat()) {
    printf("数据文件INPUT.TXT不能打开!\n\007") ;
    return ;
  }
  upOrlow() ;
  WriteDat() ;
}

int ReadDat(void)
{
  FILE *fp ;
  int i = 0 ;
  char *p ;

  if((fp = fopen("input.txt", "r")) == NULL) return 1 ;
  while(fgets(xx[i], 200, fp) != NULL) {
    p = strchr(xx[i], '\n') ;
    if(p) xx[i][p - xx[i]] = 0 ;
    i++ ;
  }
  maxline = i ;
  fclose(fp) ;
  return 0 ;
}

void WriteDat(void)
{
  FILE *fp ;
  int i ;
  fp = fopen("output.txt", "w") ;
  for(i = 0 ; i < maxline ; i++) {
    printf("%s\n", xx[i]) ;
    fprintf(fp, "%s\n", xx[i]) ;
  }
  fclose(fp) ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -