昨日、C++でなければならない新しいアカウントプログラムの大きな契約について投稿しました。私の質問は終わりましたが、多くのエラーがあったためだと思います。多くの作業と地元のC++専門家からの相談により、私は元のコードを修正しました。
#include <accounting.h>
#include <stdio.h>
char *main()
{
accounting bank = 100debits;
bank = bank + 200debits;
return printf("bal: %accounting\n", bank);
}
そして、私たちが定義したいくつかのクラスを持つ新しいバージョンはうまく機能しますが、唯一の問題は、C++がファイルに新しい行を書き込めないことです。以下のコードはそのまま機能しますが、コメント行を戻すとファイルに出力されません。
#include <stdlib.h>
#include <stdio.h>
#include <cstring>
#define accounting float
#define print_accounting(x) x "%0.2f"
#define debits * 1.0F
#define credits * -1.0F
int main()
{
accounting bank = 100 debits;
bank = bank + 200 debits;
char my_bal[((unsigned short)-1)];
sprintf(my_bal, print_accounting("bal:"), bank);
char write_file[((unsigned short)-1)];
write_file[NULL] = 0;
strcat(write_file, "@echo ");
strcat(write_file, my_bal);
// strcat(write_file, "\n"); -- Wont work --
strcat(write_file, " > c:\\SAP_replace\\bal.txt");
system(write_file);
return 0;
}