-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframe.c
More file actions
54 lines (39 loc) · 701 Bytes
/
frame.c
File metadata and controls
54 lines (39 loc) · 701 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
45
46
47
48
49
50
51
52
53
54
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"cs50.h"
#define MAX 2000
int main (void)
{
string S = GetString();
char copy1[MAX];
strcpy(copy1, S);
int max = 0;
string word = strtok(S, " ");
do
{
max = (max >= strlen(word)? max: strlen(word));
}
while (word = strtok(NULL, " "));
//Printing the frame
int i;
for (i = 0; i < max+4; i++)
{
printf("#");
}
puts("");
word = strtok(copy1, " ");
do
{
printf("# "); printf("%s", word);
for (i = strlen(word); i < max+1; i++)
printf(" ");
printf("#\n");
}
while (word = strtok(NULL, " "));
for (i = 0; i < max+4; i++)
{
printf("#");
}
return 0;
}