首页上一页 1  下一页尾页 4 条记录 1/1页
        程序运行错误   宋向佩
                 	
                        发表在C语言图书答疑
                        2010-09-25                                                
                    		
                                                                            	
                        
                        
                    
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    
                                           我买的是《VC++开发实战宝典》,书中的第二章例2.12中的程序在运行的过程中老是弹出
ompiling...
Cpp1.cpp
c:\documents and settings\administrator\桌面\cpp1.cpp(4) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
执行 cl.exe 时出错.
Cpp1.exe - 1 error(s), 0 warning(s)
程序如下,麻烦老师们给指点下
// EncryptString.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
//加密函数
bool Encrypt(const char szText[], unsigned int nTextLen,
char szOutString[], unsigned int nOutLen)
{
if (nTextLen <=0 || nOutLen < nTextLen) //验证数组长度是否合法
{
return false;
}
char chLetter; //定义一个字符变量
for(int i=0; i<nTextLen-1; i++) //遍历szText字符串
{
chLetter = szText[i] + i + 10; //设置加密字符
szOutString[i] = chLetter;
}
szOutString[i] = '\0';
return true;
}
//解密函数
bool Decrypt(const char szText[], unsigned int nTextLen,
char szOutString[], unsigned int nOutLen)
{
if (nTextLen <=0 || nOutLen < nTextLen) //验证数组长度是否合法
{
return false;
}
char chLetter;
for(int i=0; i<nTextLen-1; i++) //遍历szText字符串
{
chLetter = szText[i] - i - 10; //设置解密字符
szOutString[i] = chLetter;
}
szOutString[i] = '\0';
return true;
}
int main(int argc, char* argv[])
{
char szText[] = "mrsoft"; //定义一个字符串
char szRet[sizeof(szText) / sizeof(char)] = {0}; //记录加密后的密文
char szDecrypt [sizeof(szText) / sizeof(char)] = {0}; //记录解密后的明文
if (Encrypt(szText, sizeof(szText), szRet,
sizeof(szRet) / sizeof(char))) //字符串加密
{
cout << szText << "的密文是:" << szRet <<endl; //输出密文
}
if (Decrypt(szRet, sizeof(szRet) / sizeof(char),
szDecrypt, sizeof(szDecrypt) / sizeof(char))) //字符串解密
{
cout << szRet << '\0' << "的明文是: " << szDecrypt << endl; //输出明文
}
return 0;
}
                
        	
        
        
    ompiling...
Cpp1.cpp
c:\documents and settings\administrator\桌面\cpp1.cpp(4) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
执行 cl.exe 时出错.
Cpp1.exe - 1 error(s), 0 warning(s)
程序如下,麻烦老师们给指点下
// EncryptString.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
//加密函数
bool Encrypt(const char szText[], unsigned int nTextLen,
char szOutString[], unsigned int nOutLen)
{
if (nTextLen <=0 || nOutLen < nTextLen) //验证数组长度是否合法
{
return false;
}
char chLetter; //定义一个字符变量
for(int i=0; i<nTextLen-1; i++) //遍历szText字符串
{
chLetter = szText[i] + i + 10; //设置加密字符
szOutString[i] = chLetter;
}
szOutString[i] = '\0';
return true;
}
//解密函数
bool Decrypt(const char szText[], unsigned int nTextLen,
char szOutString[], unsigned int nOutLen)
{
if (nTextLen <=0 || nOutLen < nTextLen) //验证数组长度是否合法
{
return false;
}
char chLetter;
for(int i=0; i<nTextLen-1; i++) //遍历szText字符串
{
chLetter = szText[i] - i - 10; //设置解密字符
szOutString[i] = chLetter;
}
szOutString[i] = '\0';
return true;
}
int main(int argc, char* argv[])
{
char szText[] = "mrsoft"; //定义一个字符串
char szRet[sizeof(szText) / sizeof(char)] = {0}; //记录加密后的密文
char szDecrypt [sizeof(szText) / sizeof(char)] = {0}; //记录解密后的明文
if (Encrypt(szText, sizeof(szText), szRet,
sizeof(szRet) / sizeof(char))) //字符串加密
{
cout << szText << "的密文是:" << szRet <<endl; //输出密文
}
if (Decrypt(szRet, sizeof(szRet) / sizeof(char),
szDecrypt, sizeof(szDecrypt) / sizeof(char))) //字符串解密
{
cout << szRet << '\0' << "的明文是: " << szDecrypt << endl; //输出明文
}
return 0;
}

 
	
                                                 VIP会员
VIP会员 购物车
购物车

 私信
                         私信 
                     发表新帖
发表新帖 立即签到
立即签到 
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
               			  
                







 
                     
                     
					 
						 
						 
						 
						