C++ Saved Program: gifted-home

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include <iostream>
using namespace std;

int main() {
using System;
using System.IO;
 
public class Modify
{
  public static void Main(string[] args)
  {
    byte[] vals = new byte[args.Length-2];
    for (int i = 0; i < vals.Length; i++)
      vals[i] = byte.Parse(args[i+2],System.Globalization.NumberStyles.HexNumber);
   
    new Modify(args[0], int.Parse(args[1],System.Globalization.NumberStyles.HexNumber), vals);
  }
 
  public Modify(string file, int offset, params byte[] vals)
  {
    Stream strm = File.Open(file, FileMode.Open);
    Stream strm_new = File.Create("modified_" + file);
 
    BinaryReader reader = new BinaryReader(strm);
    BinaryWriter writer = new BinaryWriter(strm_new);
 
    writer.Write(reader.ReadBytes(offset));
 
    foreach (byte b in vals)
    {
      writer.Write(b);
    }
 
    reader.ReadBytes(vals.Length);
   
    byte[] rest = reader.ReadBytes((int)(strm.Length - vals.Length));
    writer.Write(rest);
 
    writer.Close();
    reader.Close();
    strm.Close();
    strm_new.Close();
  }
}

	
	std::cout << "This is online C/C++ compiler" << std::endl;
	return 0;
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs