Below is my full code:
#include<iostream>
#include<string.h>
int main()
{
char x[100];
int i, pos=0, l;
std::cout<<"Enter a string: ";
gets(x);
l=strlen(x);
for(i=0;i<l;i++)
{
if(x[i]==' ')
pos+=1;
x[i]=x[i+pos];
if(x[i]=='\0')
break;
}
std::cout<<"The final string is: "<<x;
fflush(stdin);
getchar();
return 0;
}
But the output is not coming as expected... Would be very happy if someone pointed out the mistake...
Aucun commentaire:
Enregistrer un commentaire