what is the use of
strcpy(c," ");
strcat(c,a); in the program? why is it used? and what would have happened if it was not used?
plz help.
// Program to implement reversing the sentence
// ex an apple a day
// output : day a apple an
#include
#include
#include
#include
void main()
{
clrscr();
int l,l1,i,j,k=0;
char a[50],b[50],c[50];
cout<<"enter a sentence";
gets(a);
l=strlen(a);
strcpy(c," "); ////////////////
strcat(c,a); ///////////////
for(i=l-1;i>=0;i--)
{
if(a[i]!=' ')
{
b[k]=a[i];
k=k+1;
}
else {
b[k]='\0';
k=0;
l1=strlen(b);
for(j=l1-1;j>=0;j--)
{
cout<
}
cout<<" ";
}
}
cout<
cout<<"Program over.....press any key to continue";
getch();
}
i understood the program except the two lines marked there.
plz help.
just answer 3 questions--->
WHAT IS ITS USE?
WHY IS IT USED?
WHAT IF THAT WAS NOT USED?
2007-01-06
01:26:56
·
7 answers
·
asked by
priya .
1
in
Programming & Design