質問編集履歴

2

誤字

2020/03/08 04:06

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- 今C言語を学んでいるうものです。scanfを使って、空白を含んだ文字を入力することは成功したのですが、その後に内容確認をするためのパートで入力したものをprintfを使って表示したいのですができません。下に書いてある警告が表示されるのでが、解決策がわからず困っています。
3
+ 今C言語を学んでいるうものです。scanfを使って、空白を含んだ文字を入力することは成功したのですが、その後に内容確認をするためのパートで入力したものをprintfを使って表示したいのですができません。下に書いてある警告が表示されるのでが、解決策がわからず困っています。
4
4
 
5
5
 
6
6
 

1

記入忘れ

2020/03/08 04:06

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -32,6 +32,8 @@
32
32
 
33
33
  ### 該当のソースコード
34
34
 
35
+ ```ここに言語を入力
36
+
35
37
 
36
38
 
37
39
  //contacts.h
@@ -80,9 +82,9 @@
80
82
 
81
83
 
82
84
 
83
-
84
-
85
- ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
85
+ ``````ここに言語を入力
86
+
87
+ ```C
86
88
 
87
89
  #define _CRT_SECURE_NO_WARNINGS
88
90
 
@@ -172,12 +174,72 @@
172
174
 
173
175
 
174
176
 
175
-
176
-
177
- printf("Do you want to enter an apartment number? (y or n): ");// ask whether need apartment num
177
+ printf("Do you want to enter an apartment number? (y or n): ");¥
178
+
179
+ do
180
+
181
+ {
182
+
183
+ scanf("%c", &choice);
184
+
185
+
186
+
187
+
188
+
189
+ if (choice == 'y' || choice == 'Y')
190
+
191
+ {
192
+
193
+ printf("Please enter the contact's apartment number: ");//apartment num
194
+
195
+ scanf("%d", &uAddress.apartmentNumber);
196
+
197
+ }
198
+
199
+ } while (choice=='\n');
200
+
201
+
202
+
203
+ printf("Please enter the contact's postal code: ");
204
+
205
+ scanf("%2s%*[^\n]",uAddress.postalCode);
206
+
207
+ printf("Please enter the contact's city: ");
208
+
209
+ scanf("%2s%*[^\n]", uAddress.city);
210
+
211
+ //end
212
+
213
+
214
+
215
+
216
+
217
+ // Contact Numbers
218
+
219
+ printf("Do you want to enter a cell phone number? (y or n): ");
220
+
221
+ do
222
+
223
+ {
224
+
225
+ scanf("%c", &choice);
178
226
 
179
227
 
180
228
 
229
+ if (choice == 'y' || choice == 'Y')
230
+
231
+ {
232
+
233
+ printf("Please enter the contact's cell phone number: ");
234
+
235
+ scanf("%s", uNumbers.cell);
236
+
237
+ };
238
+
239
+ } while (choice=='\n');
240
+
241
+ printf("Do you want to enter a home phone number? (y or n): ");
242
+
181
243
  do
182
244
 
183
245
  {
@@ -186,61 +248,23 @@
186
248
 
187
249
 
188
250
 
189
-
190
-
191
- if (choice == 'y' || choice == 'Y')
192
-
193
- {
194
-
195
- printf("Please enter the contact's apartment number: ");//apartment num
196
-
197
- scanf("%d", &uAddress.apartmentNumber);
198
-
199
- }
200
-
201
- } while (choice=='\n');
202
-
203
-
204
-
205
- printf("Please enter the contact's postal code: ");
206
-
207
- scanf("%2s%*[^\n]",uAddress.postalCode);
208
-
209
- printf("Please enter the contact's city: ");
210
-
211
- scanf("%2s%*[^\n]", uAddress.city);
212
-
213
- //end
214
-
215
-
216
-
217
-
218
-
219
- // Contact Numbers
220
-
221
- printf("Do you want to enter a cell phone number? (y or n): ");
222
-
223
- do
224
-
225
- {
226
-
227
- scanf("%c", &choice);
228
-
229
251
 
230
252
 
253
+
254
+
231
- if (choice == 'y' || choice == 'Y')
255
+ if (choice == 'y' || choice == 'Y')
232
-
256
+
233
- {
257
+ {
234
-
258
+
235
- printf("Please enter the contact's cell phone number: ");
259
+ printf("Please enter the contact's home phone number: ");
236
-
260
+
237
- scanf("%s", uNumbers.cell);
261
+ scanf("%s", uNumbers.home);
238
262
 
239
263
  };
240
264
 
241
265
  } while (choice=='\n');
242
266
 
243
- printf("Do you want to enter a home phone number? (y or n): ");
267
+ printf("Do you want to enter a business phone number? (y or n): ");
244
268
 
245
269
  do
246
270
 
@@ -250,46 +274,20 @@
250
274
 
251
275
 
252
276
 
253
-
254
-
255
-
256
-
277
+
278
+
257
- if (choice == 'y' || choice == 'Y')
279
+ if (choice == 'y' || choice == 'Y')
258
-
280
+
259
- {
281
+ {
260
-
282
+
261
- printf("Please enter the contact's home phone number: ");
283
+ printf("Please enter the contact's business phone number: ");
262
-
284
+
263
- scanf("%s", uNumbers.home);
285
+ scanf("%s", uNumbers.business);
264
286
 
265
287
  };
266
288
 
267
289
  } while (choice=='\n');
268
290
 
269
- printf("Do you want to enter a business phone number? (y or n): ");
270
-
271
- do
272
-
273
- {
274
-
275
- scanf("%c", &choice);
276
-
277
-
278
-
279
-
280
-
281
- if (choice == 'y' || choice == 'Y')
282
-
283
- {
284
-
285
- printf("Please enter the contact's business phone number: ");
286
-
287
- scanf("%s", uNumbers.business);
288
-
289
- };
290
-
291
- } while (choice=='\n');
292
-
293
291
  //end
294
292
 
295
293
 
@@ -316,66 +314,46 @@
316
314
 
317
315
  printf("Street number: %d\n", uAddress.streetNumber);
318
316
 
317
+   printf("Street name: %2s%*[^\n]", uAddress.street);
318
+
319
+ printf("Apartment: %d\n", uAddress.apartmentNumber);
320
+
321
+ printf("Postal code: %s", uAddress.postalCode);
322
+
323
+ printf("City: %s\n\n", uAddress.city);
324
+
325
+
326
+
327
+ printf("Phone Numbers:\n");
328
+
329
+ printf("Cell phone number: %s\n", uNumbers.cell);
330
+
331
+ printf("Home phone number: %s\n", uNumbers.home);
332
+
333
+ printf("Business phone number: %s\n\n", uNumbers.business);
334
+
335
+
336
+
337
+
338
+
319
- `````````ここに言語を入力
339
+ // Completion Message
340
+
320
-
341
+ printf("Structure test for Name, Address, and Numbers Done!\n");
342
+
343
+
344
+
345
+
346
+
321
- ここに言語を入力
347
+ return 0;
348
+
349
+ }
350
+
351
+
352
+
353
+
322
354
 
323
355
  ```
324
356
 
325
- ここに言語を入力
357
+
326
358
 
327
359
  ```
328
-
329
- コード
330
-
331
- ```printf("Street name: %2s%*[^\n]", uAddress.street);
332
-
333
- printf("Apartment: %d\n", uAddress.apartmentNumber);
334
-
335
- printf("Postal code: %s", uAddress.postalCode);
336
-
337
- printf("City: %s\n\n", uAddress.city);
338
-
339
-
340
-
341
- printf("Phone Numbers:\n");
342
-
343
- printf("Cell phone number: %s\n", uNumbers.cell);
344
-
345
- printf("Home phone number: %s\n", uNumbers.home);
346
-
347
- printf("Business phone number: %s\n\n", uNumbers.business);
348
-
349
-
350
-
351
-
352
-
353
- // Completion Message
354
-
355
- printf("Structure test for Name, Address, and Numbers Done!\n");
356
-
357
-
358
-
359
-
360
-
361
- return 0;
362
-
363
- }
364
-
365
-
366
-
367
-
368
-
369
- ### 試したこと
370
-
371
-
372
-
373
- ここに問題に対して試したことを記載してください。
374
-
375
-
376
-
377
- ### 補足情報(FW/ツールのバージョンなど)
378
-
379
-
380
-
381
- ここにより詳細な情報を記載してください。