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;
}

  

时间: 2024-08-05 11:16:50

VC读取文件内容的相关文章

asp.net 上传XML,txt 直接读取文件内容

if (GetUploadFileContent.PostedFile.InputStream.Length < 1) { Msg.Text = "请选择文件";return; } string FileName = GetUploadFileContent.FileName;//上传文件文件名 string FilePath = GetUploadFileContent.PostedFile.FileName;//上传文件完整路径+文件名string fileExtName =

PHP读取文件内容的五种方式

php读取文件内容的五种方式 分享下php读取文件内容的五种方法:好吧,写完后发现文件全部没有关闭.实际应用当中,请注意关闭 fclose($fp);-- php读取文件内容: -----第一种方法-----fread()-------- ? 1 2 3 4 5 6 7 8 <?php $file_path = "test.txt"; if(file_exists($file_path)){ $fp = fopen($file_path,"r"); $str

使用ifstream和getline读取文件内容[c++]

转载:http://www.cnblogs.com/JCSU/articles/1190685.html 假设有一个叫 data.txt 的文件, 它包含以下内容: Fry: One Jillion dollars. [Everyone gasps.] Auctioneer: Sir, that's not a number. 数据读取, 测试 . 以下就是基于 data.txt 的数据读取操作: #include <iostream> #include <fstream> #in

7 RandomAccessFile读取文件内容保存--简单例子(需要验证)

1 import org.slf4j.Logger; 2 import org.slf4j.LoggerFactory; 3 4 import java.io.*; 5 6 /** 7 * 读取动态产生的文件内容 8 */ 9 public class RandomAccessRead { 10 public static Logger logger= LoggerFactory.getLogger(RandomAccessRead.class); 11 12 //文件默认读取位置为从开始读取

php读取文件内容的三种方式(转)

分享下php读取文件内容的三种方法. php读取文件内容: //**************第一种读取方式***************************** header("content-type:text/html;charset=utf-8"); //文件路径 $file_path="text.txt"; //判断是否有这个文件 if(file_exists($file_path)){ if($fp=fopen($file_path,"a+&

Python逐行读取文件内容

Python逐行读取文件内容thefile= open("foo.txt") line = thefile.readline() while line: print line, line = thefile.readline() thefile.close() Windows下文件路径的写法:E:/codes/tions.txt 写文件:thefile= open("foo.txt", "rw+")for item in thelist: the

nodejs常见的读取文件内容的方法

nodejs常见的读取文件内容的方法 by 伍雪颖 var fs = require('fs'); var rs = fs.createReadStream('test.md'); var data = ''; rs.on("data",function(chunk) { data += chunk; }); rs.on("end",function() { console.log(data); });

shell读取文件内容

Shell脚本,执行解释速度快.代码简单易于理解.在shell代码编写过程中,经常会用到读取文件内容. 写法一: ---------------------------------------------------------------------------- #!/bin/bash while read line do echo $line done < file(待读取的文件) ------------------------------------------------------

Python跳过第一行读取文件内容

Python编程时,经常需要跳过第一行读取文件内容.比较容易想到是为每行设置一个line_num,然后判断line_num是否为1,如果不等于1,则进行读取操作.相应的Python代码如下: [python] view plain copy input_file = open("C:\\Python34\\test.csv") line_num = 0 for line in islice(input_file, 1, None): line_num += 1 if (line_num