I was creating a code for rotation of specif number in a string and initially i created it for one user input ! It worked as soon as i added on logic for multiple test case its is showing floating point exception.....
can anyone tell me in the code what caused that error !
#include<iostream>
#include<cstring>
using namespace std;
void stringrot(char str[],int n)
{
int l=strlen(str);
char temp[100];
int k=n%l;
for(int i=0;i<k;i++)
{
temp[i]=str[(l-k+i)];
}
for(int i=0;i<l-k;i++)
{
temp[k+i]=str[i];
}
temp[l]='\0';
cout<<temp;
}
int main()
{
int test;
cin>>test;
while(--test>=0)
{
char str[100];
cin.getline(str,50);
int n;
cin>>n;
stringrot(str,n);
}
}
Here is the code !