當前位置:首頁 » 編程語言 » c語言綱要

c語言綱要

發布時間: 2023-03-08 06:48:25

『壹』 c語言如何按行讀取txt中的中文字元

//若使用一維數組使用以下程序
#include <stdio.h>
main()
{
char s1[20] = {0};
char s2[20] = {0};
char s3[20] = {0};
int i=0;
FILE *fp;
fp = fopen("1.txt","r");
fscanf(fp,"%s",s1);
fscanf(fp,"%s",s2);
fscanf(fp,"%s",s3);
printf("%s\n%s\n%s\n",s1,s2,s3);

}

//若用二維數組使用如下程序
#include <stdio.h>
main()
{
char s[10][20] = {0};
int i=0;
FILE *fp;
fp = fopen("1.txt","r");
for(i=0;i<3;i++)
{
fscanf(fp,"%s",s[i]);
printf("%s\n",s[i]);
}
}

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:596
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:890
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:583
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:767
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:687
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1015
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:258
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:117
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:808
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:715