Hello coders,
I've been working or this for the past two days,the code is supposed to go through the string and every time there are similar characters it's supposed to increment the counter. An input of "303030404040" is supposed to print out "303403" but its printing bogus data!! please help
#include <iostream> // std::cout
#include <iomanip>
#include <string> // std::string, std::to_string
#include <stdlib.h> /* atof */
#include <math.h>
#include<sstream>
#include <cstring>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
string integerrunlengthencoding(string hextext) {
int counter=1;
int length = hextext.size();
string output = "";
for(int i=0;i<length -1;i=i+2){
for(int k=1;k<length;k=k+2){
if(hextexts[i] == hextexts[i+2]){
if(hextexts[k] == hextexts[k+2] ){
counter++;
} else{
output = output + hextexts[i] + hextexts[k] + std::to_string(counter);