I have a simple run length encoding algorithim written in C#
List<byte> list = new List<byte>();
for (int i = 0; i < str.Length; i++)
{
byte b = 1;
char c;
for (c = str[i]; i + 1 < str.Length && str[i + 1] == c; i++)
{
if (b >= byte.MaxValue)
{
break;
}
b = (byte)(b + 1);
}
list.Add(b);
list.Add((byte)c);
}
return list.ToArray();
That I intend to have run against a given input, and have an output generated, containing the inputs data, now encoded with the above algorithm. What are some ways I can achieve this? I'm very VERY new to C, C#, C++ and the like some I'm a bit out of my depth with this.
1- Create a new console application in C# using Visual Studio
2- Edit program.cs, declare your script as static function which takes an input string and returns byte[] call it EncodeString