-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp05ex09.c
More file actions
48 lines (42 loc) · 738 Bytes
/
Copy pathp05ex09.c
File metadata and controls
48 lines (42 loc) · 738 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
/*** p05ex09.c ***/
/*** ps20 ***/
#include <stdio.h>
void reverseString(char s[])
{
int len = 0;
int i;
int j = 0;
char tmp[30];
while (s[len] != '\0')
{
++len;
}
for (i = len - 1; i >= 0; i--)
{
tmp[j] = s[i];
++j;
}
tmp[j] = '\0';
for (i = 0; i < len; i++)
{
s[i] = tmp[i];
}
}
int main()
{
char str[30] = "exercises";
char str2[30] = "java";
printf("--!%s!--\n", str);
reverseString(str);
printf("--!%s!--\n", str);
printf("--!%s!--\n", str2);
reverseString(str2);
printf("--!%s!--\n", str2);
return 0;
}
/*** 結果 ***
--!exercises!--
--!sesicrexe!--
--!java!--
--!avaj!--
*************/