酷!學園

技術討論區 => 程式討論版 => C/C++程式設計討論區 => 主題作者是: viake 於 2010-07-13 00:00

主題: 想讀取a.jed檔案顯示
作者: viake2010-07-13 00:00
這是小弟打的程式
是想要將a.jed的檔案裡的東西讀取出來
但好像在fileopen=fopen("s","r");這裡有問題
一直無法將我輸入的檔案讀取
又或者是要在哪裡加入顯示
每個顯示完是否都要加fclose呢
我想要做的像附件裡頭的eddie.exe黨那樣顯示a.jed檔
請問還甚麼麼地方應該要修改
還有該去讀哪些指令,或是怎麼google呢
我是要用C語言寫的
沒有要用C++...因為之前有人有發過文章...但是是用C++寫的
看不太懂
謝謝
[attachment=1]
[attachment=2]


#include "stdafx.h"
#include <stdio.h>
int main(void)
{
   char c,c1,c2,s,a;//s:存檔案路徑名稱,a:存位址,c1:all的選擇,c2:位址顯示選擇
   printf("please Enter File name: ");
   s=getchar();//將輸入檔明存至S中
   //開啟file
   FILE *fileopen;
   fileopen=fopen("s","r");//
   {
   if(fileopen==NULL)
      printf("cannot open the file\n");
      fclose(fileopen);
   else
   {
      printf("===============================================\n");
      printf("\n");//用來顯示檔案最後的位址
      printf("===============================================\n");
      printf("1.show all data.\n");
      printf("2.input start address.\n");
      printf("choose 1 or 2 :");
      scanf("%s",&s);
      switch(c)
      {
         case'1':printf("===============================================\n");
               printf("1:show all data.(once)\n");
               printf("2:show all data.(page)\n");
               printf("choose 1 or 2 :");
               scanf("%s",&c1);;
               switch(c1)
                  {
                  case'1':printf("show all data.(once)\n");
                        //跳至一次顯示
                        break;
                  case'2':printf("show all data.(page)\n");
                        //跳至逐頁顯示
                        break;
                  default:printf("erro\n");//輸入錯誤
                   }                                          
         case'2':printf("===============================================\n");
               printf("Please enter start address:");
               scanf("%s",&a);
               printf("1:show the data.(once)\n");
               printf("1:show the data.(once)\n");
               printf("2:show the data.(page)\n");
               printf("choose 1 or 2 :");
               scanf("%s",&c2);
               switch(c2)
               {
               case'1':printf("===============================================\n");
                  printf("1:show the data.(once)\n");
                  //從輸入位址開始一次顯示
                  break;
               case'2':printf("===============================================\n");
                  printf("1:show the data.(page)\n");
                  //從輸入位址開始逐頁顯示
                  break;
               default:printf("===============================================\n");
                  printf("error.\n");//輸入錯誤
               }
         default:printf("===============================================\n");
            printf("error.\n");//輸入錯誤
      }
   }
   }
   return(0);
}
主題: 回覆: 想讀取a.jed檔案顯示
作者: §そし嵐§2010-07-13 14:29
這麼難的程式應該沒有人會回答吧~~~
因為似乎有很多有關連的部分都是錯誤的
所以要改的話就要改全部哩~~