prev


Character Arrays - String manipulations:

82.Copy last n character (13.05.2010)

/*
Program# 82
date : 28-12-2008
Copy last 'n' char
*/

#include <stdio.h>
main(){
char a[100],b[100];
int i,n,j;

i=0;
scanf("%c",&a[i]);
while(a[i]!='$'){
i++;
scanf("%c",&a[i]);
}
a[i]='\0';
scanf("%d",&n);

j=i-n;
i=0;
while(a[j]!='\0'){
b[i++]=a[j++];

}
b[i]='\0';
printf("\n %s\n %s",a,b);
}



next
blog comments powered by Disqus