Hello Everyone i am trying to write a program for printing all the combinations of a string.I do not want any help regarding the algorithm but i need help figuring out why this program is giving the error message
"First-chance exception at 0x761bc41f in word.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0026f6b4..
Unhandled exception at 0x761bc41f in word.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0026f6b4.." when i try to run this in MVS 2010
#include<iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<conio.h>
void combination(std::string input,int length,std::string buffer,int allowedno)
{
for(int i =allowedno;i<length;i++)
{
buffer.at(i)=input.at(i);
std::cout << buffer<< '\n';
if(i!=length)
{
combination(input,length,buffer,i+1);
}
buffer.erase(length-1);
}
}
void combine(std::string input)
{
int length=input.size();
//char *buffer = (char *)malloc(sizeof(char)*(length+1));
std::string buffer(input);
buffer.erase();
combination(input,length,buffer,0);
}
void main()
{
std ::string input= "ABC";
combine(input);
getch();
}