S
Shamprikta Mehreen
Guest
The compiler is throwing me this error: Run-Time Check Failure #2 - Stack around the variable 'newarray1' was corrupted.
Please tell me what to do. Here is my code
#include <iostream>
using namespace std;
void leftshift(char text[], int n)
{
int i;
char newarray1[6] = { '\0' };
for (i = 0; i < n; i++)
{
newarray1 = text;
}
char temp = newarray1[0];
for ( i = 0; i <= n - 1; i++)
{
newarray1[i-1]=newarray1;
}
newarray1[n - 1] = temp;
cout << newarray1;
}
int main()
{
char text[6]= { '\0' };
for (int i = 0; i < 5; i++)
{
cin >> text;
}
int n=sizeof(text);
cin >> n;
for (int i = 0; i < n; i++)
{
cout << text;
}
cout<< endl;
leftshift(text,5);
system("PAUSE");
return 0;
}
Continue reading...
Please tell me what to do. Here is my code
#include <iostream>
using namespace std;
void leftshift(char text[], int n)
{
int i;
char newarray1[6] = { '\0' };
for (i = 0; i < n; i++)
{
newarray1 = text;
}
char temp = newarray1[0];
for ( i = 0; i <= n - 1; i++)
{
newarray1[i-1]=newarray1;
}
newarray1[n - 1] = temp;
cout << newarray1;
}
int main()
{
char text[6]= { '\0' };
for (int i = 0; i < 5; i++)
{
cin >> text;
}
int n=sizeof(text);
cin >> n;
for (int i = 0; i < n; i++)
{
cout << text;
}
cout<< endl;
leftshift(text,5);
system("PAUSE");
return 0;
}
Continue reading...