If we are given a string for instance abcdef and k=2 , so output should be cdefab , i.e. first two characters are appended at end
Here's my code , please tell where's the mistake :
#include<stdio. h>
int main()
{
int count=0,a=0,len gth=0;
char name[]="abcdef";
char *ptr,*ptr1;
ptr=name;
ptr1=name;
char *name1=name;
while(*ptr!='\0 ')
{
length++;
ptr++;
}
printf("enter the position by which you have to rotate ");
scanf("%d",&cou nt);
while(a<length )
{
*ptr++=*ptr1++;
name[a]='\0';
name1++;
a++;
}
name1++;
*ptr='\0';
printf("%s",nam e1);
return 0;
}
Here's my code , please tell where's the mistake :
#include<stdio. h>
int main()
{
int count=0,a=0,len gth=0;
char name[]="abcdef";
char *ptr,*ptr1;
ptr=name;
ptr1=name;
char *name1=name;
while(*ptr!='\0 ')
{
length++;
ptr++;
}
printf("enter the position by which you have to rotate ");
scanf("%d",&cou nt);
while(a<length )
{
*ptr++=*ptr1++;
name[a]='\0';
name1++;
a++;
}
name1++;
*ptr='\0';
printf("%s",nam e1);
return 0;
}
Comment