回文章列表
作者loquito.bbs@bbs.yuntech.edu.tw (snowflake), 信區: sources
標題Re: [問題] C語言的檔案開啟
時間雲林科技大學藍天使 BBS (Thu Sep 16 14:40:55 2004)
轉信站: GIBBS!news2.ncku!ccnews.ncku!news.ccns.ncku!news.civil.ncku!news.ntust!

※ 引述《fon.bbs@binary.csie.ncu.edu.tw (fon)》之銘言:
> 我想做個可以開啟檔案的程式如下:
> 01 #include<stdio.h>
> 02 viod main()
> 03 {
> 04   char name[13],ch;
> 05   printf("input file name:\n");
> 06   scanf("%s",&name);
> 07   FILE *fp;
> 08   fp=fopen(name,"r");
> 09   while ( (ch=getc(fp))!=EOF)
> 10     printf("%c",ch);
> 11   fclose(fp);
> 12 }
> 但compile時發生錯誤
> 如果把05、06刪掉,04改為 (aaaaaaaa.txt為已存在的檔案)
> char name[13]="aaaaaaaa.txt",ch;
> 就可以進行compile了
> 問題到底是出在那,麻煩各位幫幫我


What does the compile error says????
I'm not sure, but try the following:
06 scanf("%s",name);

"name" is defined as a array's name, I think it is already a pointer.
--
※ Origin: 雲林科技大學藍天使 <bbs.yuntech.edu.tw> [From: 140.125.10.71]
文章選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻