Here's the code :
void main()
{
int i,n;
char *x="Alice";
n=strlen(x);
*x=x[n];
for(i=0;i<=n;i++)
{
cout<<x<<" ";
}
cout<<endl<<x;
getch();
}
The output is :
lice ice ce e
Can you please explain what happens in every step?
Thanks! :D
I was told to find output for this program and then explain it to my class. I don't really understand how it works though. :/
Did you run the program?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int i,n;
char *x="Alice";
n=strlen(x);
*x=x[n];
for(i=0;i<=n;i++)
{
cout<<x<<" ";
}
cout<<endl<<x;
cin.get();
}
|
There is nothing in your program output.
Last edited on
The output is :
lice ice ce e
I got this using turboc++