[問題] switch...case的問題
開發平台(Platform): (Ex: Win10, Linux, ...)
Win7
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
Dev C++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
stdio.h stdlib.h
問題(Question):
為什麼我的switch...case,無法成功載入,會直接跳default:("Error\n);
餵入的資料(Input):
預期的正確結果(Expected Output):
printf("Choice your mode: A.Read B.Write C.Randread D.Randwrite E.Randr
F.RWmixread=70 \n");
scanf("%c", &mode);
輸入A.B.C.D.E等,會printf出來結果
錯誤結果(Wrong Output):
結果直接跳到Error
程式碼(Code):(請善用置底文網頁, 記得排版)
#include<stdio.h>
#include<stdlib.h>
int main()
{
char filename[10];
int iodepth, bs, size, numjobs, runtime;
printf("Where is your file? (absult postion)\n");
scanf("%s", filename);
printf("Setting your IO module(default=1)\n");
scanf("%d", &iodepth);
printf("What is your I/O size(-bs)?\n");
scanf("%d", &bs);
printf("How much the test file size\n");
scanf("%d", &size);
printf("How many your number of jobs?\n");
scanf("%d", &numjobs);
printf("How long do you wany to test?(sec)\n");
scanf("%d", &runtime);
char mode;
printf("Choice your mode: A.Read B.Write C.Randread D.Randwrite E.Randrw
F.RWmixread=70 \n");
scanf("%c", &mode);
switch(mode)
{
case 'A':
printf("Fuck u\n");
printf("fio -filename=%s -direct=1 -iodepth %d -thread -rw=read
ioengine=libaio -bs=%dm -size=%dG -numjobs=%d -runtime=%d -group_reporting
-name=mytest\n", filename, iodepth, bs, size, numjobs, runtime);
break;
case 'B':
printf("fio -filename=%s -direct=1 -iodepth %d -thread -rw=write
ioengine=libaio -bs=%dm -size=%dG -numjobs=%d -runtime=%d -group_reporting
-name=mytest\n", filename, iodepth, bs, size, numjobs, runtime);
break;
case 'C':
printf("fio -filename=%s -direct=1 -iodepth %d -thread
-rw=randread ioengine=libaio -bs=%dm -size=%dG -numjobs=%d -runtime=%d
-group_reporting -name=mytest\n", filename, iodepth, bs, size, numjobs,
runtime);
break;
case 'D':
printf("fio -filename=%s -direct=1 -iodepth %d -thread
-rw=randwrite ioengine=libaio -bs=%dm -size=%dG -numjobs=%d -runtime=%d
-group_reporting -name=mytest\n", filename, iodepth, bs, size, numjobs,
runtime);
break;
case 'E':
printf("fio -filename=%s -direct=1 -iodepth %d -thread
-rw=randrw ioengine=libaio -bs=%dm -size=%dG -numjobs=%d -runtime=%d
-group_reporting -name=mytest\n", filename, iodepth, bs, size, numjobs,
runtime);
break;
default:
printf("Error\n");
}
return 0;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.251.10.52
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1504837410.A.4BB.html
推
09/08 10:32, , 1F
09/08 10:32, 1F
推
09/08 10:52, , 2F
09/08 10:52, 2F
→
09/08 11:02, , 3F
09/08 11:02, 3F
→
09/08 11:04, , 4F
09/08 11:04, 4F
→
09/08 11:05, , 5F
09/08 11:05, 5F
推
09/08 11:10, , 6F
09/08 11:10, 6F
推
09/08 11:16, , 7F
09/08 11:16, 7F
→
09/08 11:17, , 8F
09/08 11:17, 8F
→
09/08 11:19, , 9F
09/08 11:19, 9F
→
09/08 11:20, , 10F
09/08 11:20, 10F
→
09/08 11:20, , 11F
09/08 11:20, 11F
→
09/08 11:24, , 12F
09/08 11:24, 12F
→
09/08 11:24, , 13F
09/08 11:24, 13F
→
09/08 11:25, , 14F
09/08 11:25, 14F
→
09/08 11:26, , 15F
09/08 11:26, 15F
→
09/08 11:28, , 16F
09/08 11:28, 16F
→
09/08 11:32, , 17F
09/08 11:32, 17F
→
09/08 11:32, , 18F
09/08 11:32, 18F
→
09/08 11:33, , 19F
09/08 11:33, 19F
→
09/08 11:34, , 20F
09/08 11:34, 20F
→
09/08 11:36, , 21F
09/08 11:36, 21F
→
09/08 11:36, , 22F
09/08 11:36, 22F
推
09/08 11:37, , 23F
09/08 11:37, 23F
→
09/08 11:39, , 24F
09/08 11:39, 24F
→
09/08 11:39, , 25F
09/08 11:39, 25F
推
09/08 11:41, , 26F
09/08 11:41, 26F
推
09/08 11:42, , 27F
09/08 11:42, 27F
→
09/08 11:42, , 28F
09/08 11:42, 28F
→
09/08 11:44, , 29F
09/08 11:44, 29F
→
09/08 11:45, , 30F
09/08 11:45, 30F
→
09/08 11:50, , 31F
09/08 11:50, 31F
→
09/08 11:55, , 32F
09/08 11:55, 32F
→
09/08 11:56, , 33F
09/08 11:56, 33F
→
09/08 11:57, , 34F
09/08 11:57, 34F
→
09/08 12:13, , 35F
09/08 12:13, 35F
→
09/08 12:14, , 36F
09/08 12:14, 36F
→
09/08 12:14, , 37F
09/08 12:14, 37F
→
09/08 13:20, , 38F
09/08 13:20, 38F
→
09/08 14:28, , 39F
09/08 14:28, 39F
→
09/08 17:08, , 40F
09/08 17:08, 40F
→
09/08 17:10, , 41F
09/08 17:10, 41F

→
09/08 17:15, , 42F
09/08 17:15, 42F
→
09/08 17:30, , 43F
09/08 17:30, 43F
→
09/08 17:30, , 44F
09/08 17:30, 44F
推
09/08 20:18, , 45F
09/08 20:18, 45F
→
09/08 20:18, , 46F
09/08 20:18, 46F
推
09/08 21:47, , 47F
09/08 21:47, 47F
→
09/08 21:47, , 48F
09/08 21:47, 48F
→
09/08 21:47, , 49F
09/08 21:47, 49F
→
09/11 13:47, , 50F
09/11 13:47, 50F
→
09/11 13:47, , 51F
09/11 13:47, 51F