Character count
Fri Nov 15 2024 15:43:07 GMT+0000 (Coordinated Universal Time)
Saved by
@login
#include<stdio.h>
#include<string.h>
int main(){
int n,i,j,c=0,count=0;
char str[100];
printf("Enter the string: ");
scanf("%s", str);
printf("Enter the number of frames:");
scanf("%d",&n);
int frames[n];
printf("Enter the frame size of the frames:\n");
for(int i=0;i<n;i++){
printf("Frame %d:",i);
scanf("%d",&frames[i]);
}
printf("\nThe number of frames:%d\n",n);
c = 0;
for(int i=0;i<n;i++){
printf("The content of the frame %d:",i);
j=0;
count = 0;
while(c < strlen(str) && j < frames[i]){
printf("%c",str[c]);
if(str[c]!='\0'){
count++;
}
c=c+1;
j=j+1;
}
printf("\nSize of frame %d: %d\n\n",i,count);
}
return 0;
}
content_copyCOPY
Comments