C++二进制文档的问题

来源:百度知道 编辑:UC知道 时间:2024/05/12 14:58:09
题目要求:
已有一个文档要求以二进制格式打开,并给每一行加上行号。

给出答案和解释,好的再加20分
我要的是详细答案,判断有几行,然后再在每一行前加行号

#include <fstream>
using namespace std;

ifstream infile("filename",ios::in|ios::binary);
if(!infile)
{
//异常
}

这个是二进制打开的方式

二进制你也按行来操作?
这个实在...

只有C#的,将就着看吧:
using System;
using System.IO;

namespace cwj
{
class CopyFileAddLineNumber
{
static FileStream fout2;
static StreamWriter brout2;
public static void Main(string[] args)
{
string infname = "CopyFileAddLineNumber.cs";
string outfname = "CopyFileAddLineNumber.txt";
string outfname2 = "comments.txt";
if (args.Length >= 1) infname = args[0];
if (args.Length >= 2) outfname = args[1];
if (args.Length >= 3) outfname = args[2];

try
{
FileStream fin = new FileStre