#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; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter