VC读取文件内容

// chopper.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <WinSock2.h>
#include <Windows.h>
#include <stdlib.h>


int redpwd(char* pwd)
{
	FILE* fp;
	if ((fp = fopen(pwd,"rb")) == NULL)//以只读方式打开
	{
		printf("I'am sorry,pwd:%s not found\r\n",pwd);
		return 0;
	}

	char buf[MAX_PATH] = {0};
	int i = 0;
	while (fgets(buf,MAX_PATH,fp))//循环读取字符串
	{
		printf("已经读取密码:%d-------->读取内容 :%s \n",++i,buf);
	}
	fclose(fp);//关闭文件句柄
	return 0;
}

int main(int argc,char** argv)
{
	if (argc < 2)
	{
		printf("[-]:%s READ_File\r\n",argv[0]);
		return 0;
	}
	redpwd(argv[1]);
	return 0;
}

  

posted @ 2015-01-19 20:32  杀死比特  阅读(747)  评论(0编辑  收藏  举报