開發平台(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):