Hello. I need help with my assignment urgently. This is my assignment question and the follwoing is my code. It compiles but it doesnt give me the right output.
Run length encoding.
Example: if the input is “AAABBCCCDEEFFA” the output will be “A3B2C3DE2F2A”Input takes the form of alphabetic characters only
- Must read in the input from standard input.
Can't use C++ string data type or vectors. Only use dynamic arrays implemented with pointer.
include <iostream>include <cstdlib>include <cstring>using namespace std;
int main()
{
char str[26];
char *ptr;ptr = str; cout << "Enter a string: " << endl; cin >> ptr; char chCount; unsigned int temp = 0; //char curr; for (unsigned int i = 0; i < strlen(str); i++) { if(str[i] == chCount) temp++; else{ temp = 1; } } cout << temp << endl; //cout << "Hello world!" << endl; return 0;
}