|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include<stdio.h>
- #include<string.h>
- int main() {
- char account[30];
- int password;
- double balance;
- FILE* fp;
- errno_t err;
- if ((err = fopen_s(&fp,"clientsInfo.dat", "w")) !=0) {
- printf("fail to open the file\n");
- }
- else {
- printf("Enter the account, password and the balance:\n");
- printf("Enter EOF to end input.\n");
- while (1) {
- scanf_s("%s %d %lf", account,15, &password, &balance);
- if (strcmp(account, "EOF") == 0)
- break;
- fprintf(fp, "%s%d%.2f\n", account, password, balance);
- }
- fclose(fp);
- }
- return 0;
- }
复制代码
这是我的代码 写出来的文件是这样的
fprintf(fp, "%s%d%.2f\n", account, password, balance); 中%s与%d与%.2f应该有空格,试试看
|
|