您的位置:首页 > 其它

VC读取文件内容

2015-01-19 20:32 113 查看
// 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;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: