-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframedOut.c
More file actions
44 lines (36 loc) · 781 Bytes
/
Copy pathframedOut.c
File metadata and controls
44 lines (36 loc) · 781 Bytes
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
44
#include <stdio.h>
#include <string.h>
#define CORNER '+'
#define HORIZONTAL '-'
#define VERTICAL '|'
void printline(int textlen);
int frprint(char* input[], int lines) {
int longest = 0;
{
int currentlen;
for(int i = 0; i < lines; i++){
currentlen = strlen(input[i]);
if (currentlen > longest)
longest = currentlen;
}
}
//top line
printline(longest);
//text output
for(int line = 0; line < lines; line++){
putchar(VERTICAL);
printf("%s", input[line]);
for(int i = strlen(input[line]);i++ < longest; putchar(' '));
putchar(VERTICAL);
putchar('\n');
}
//bottom line
printline(longest);
return 0;
}
void printline(int textlen){
putchar(CORNER);
for(int i = 0; i++ < textlen; putchar(HORIZONTAL));
putchar(CORNER);
putchar('\n');
}