桃乃木香奈穿白丝的番:编程帮忙啊~~

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 14:06:15
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void trans(char temp[50][80], int j);

void main()
{
long i, j, k;
char temp[50][80];
char *str;
FILE *ifp, *ofp;

if((ifp = fopen("input.txt", "r")) == NULL)
{
printf("打开input.txt文件失败");
exit(1);
}
else
{
ofp = fopen("output.txt", "w");
}

i = 0; /* 文件读取的初始位置0 ,即从第0行开始读取文件*/
while(1)
{
/* 从文件中读取79个字符,在结尾添加上'\0'并写入数组 */
str = fgets(temp[i], 80, ifp);
//printf("转换之前:\t ");
//printf("%s", str);

/* 无可读取内容时,返回NULL */
if(str == NULL)
//if(temp[i]==NULL) //因为最后temp[i]中不一定是NULL
{
break;
}
else
{
/*调用函数计算新的ASCII码值*/
trans(temp, i);
/*将处理好的一行字符写入output.txt文件*/
//fprintf(ofp, "%s", temp[i]);//使用fprint()函数写入文件
fputs(temp[i],ofp); //使用fputs()函数写入文件

/*显示转换后的字符*/
printf("转换之后:\t ");
printf("%s",temp[i]);

i++;
}
}
fclose(ifp);
fclose(ofp);
}

void trans(char temp[50][80], int j)
{
unsigned int i;
for(i = 0; i < strlen(temp[j]); i++)
temp[j][i]=temp[j][i]+(temp[j][i] >> 4); /*ASCII码值右移4位加上原字符的ASCII码值*/
}
我看不懂啊 能给我解释解释 每一行都什么意思吗?

这个编程方面的你最好去问朋友,或者提高悬赏分,100分应该就有人答复你了