回覆列表
  • 1 # uztau1094

    是儲存ascii碼還是以ascii編碼格式儲存其實預設就是ascii儲存了下面是一個簡單的程式碼#include <stdio.h>int main(int argc,char **argv){ FILE *fp; char s[80]; scanf("%s",s); if((fp=fopen("1.txt","wb")) == NULL) return -1; fprintf(fp,"%s",s); fclose(fp); return 0;}如果是儲存ascii值的話則可以遍歷字串然後將元素的ascii值(十進位制)儲存裡檔案裡一個簡單的程式碼如下#include <stdio.h>int main(int argc,char **argv){ FILE *fp; char s[80]; int i; scanf("%s",s); if((fp=fopen("1.txt","wb")) == NULL) return -1; for(i=0;s[i];++i) fprintf(fp,"%d",s[i]); fclose(fp); return 0;}

  • 中秋節和大豐收的關聯?
  • 請大師指點!辛卯年丁酉月乙未日未時五行當中缺什麼?