-
Notifications
You must be signed in to change notification settings - Fork 0
/
mirror.c
43 lines (30 loc) · 880 Bytes
/
mirror.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
int main(){
int lineWidth = 0;
printf("Enter the length of the output line:\n");
scanf("%d", &lineWidth);
printf("Enter your text (control-d to exit):\n");
int charCount = 0;
char totChar[charCount];
char userChar[charCount];
while(!feof(stdin)){
scanf("%c", &userChar[charCount]);
totChar[charCount] = userChar[charCount];
charCount++;
}
printf("<control-d>");
int count = 0;
int timer = charCount;
int lines = charCount / lineWidth;
for (int i = 0; i < lines; i++){
for(int k = charCount; count <= lineWidth; charCount--){
printf("%c", totChar[k]);
count++;
}
printf("\n");
}
return 0;
}