質問編集履歴
1
コメントを受けてコードを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -75,3 +75,85 @@
|
|
75
75
|
|
76
76
|
|
77
77
|
```
|
78
|
+
|
79
|
+
---
|
80
|
+
|
81
|
+
コメントを受けて訂正した所無事動かすことができましたm(_ _)m
|
82
|
+
|
83
|
+
修正後コード
|
84
|
+
|
85
|
+
```C
|
86
|
+
|
87
|
+
#include <stdio.h>
|
88
|
+
|
89
|
+
#include <string.h>
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
int main(){
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
char* cmd = "hello world \" and hello universe \" ";
|
98
|
+
|
99
|
+
char args[10][100];
|
100
|
+
|
101
|
+
char* check;
|
102
|
+
|
103
|
+
char p;
|
104
|
+
|
105
|
+
int quotationFound = 0;
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
int i=0;
|
110
|
+
|
111
|
+
int j=0;
|
112
|
+
|
113
|
+
int k=0;
|
114
|
+
|
115
|
+
for(; cmd[i]!='\0'; i++){
|
116
|
+
|
117
|
+
p = cmd[i];
|
118
|
+
|
119
|
+
if(p=='\"')
|
120
|
+
|
121
|
+
quotationFound = !quotationFound;
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
args[k][j++] = p;
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
printf("p is now : %c\n", p);
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
if(p==' ' && !quotationFound){
|
134
|
+
|
135
|
+
k++; j=0;
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
printf("args[0] : %s\n", args[0]);
|
144
|
+
|
145
|
+
printf("args[1] : %s\n", args[1]);
|
146
|
+
|
147
|
+
printf("args[2] : %s\n", args[2]);
|
148
|
+
|
149
|
+
printf("args[3] : %s\n", args[3]);
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
return 0;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
```
|