現在、リモートLinux端末に接続するためにSSHを使用して実行すると正しくコンパイルされ、実行されるassign1.cという名前のファイルがあります。Cファイルの出力を別のファイルにリダイレクトするときのCプログラミングエラー
#include <stdio.h>
#define PI 3.141593
int main(){
int degrees = 0;
double radians;
printf("Degrees to Radians \n");
degrees = 0;
radians = degrees*PI/180;
printf("%6i %9.6f \n", degrees, radians);
degrees = 10;
radians = degrees*PI/180;
printf("%6i %9.6f \n", degrees, radians);
while(degrees < 350){
degrees +=10;
radians = degrees*PI/180;
printf("%6i %9.6f \n", degrees, radians);
}
degrees = 360;
radians = degrees*PI/180;
printf("%6i %9.6f \n", degrees, radians);
}
私はgccの-o PROG1 prog1.c Iをコンパイルしようとすると、しかし、異なるファイルprog1.cに
Degrees to Radians
0 0.000000
10 0.174533
20 0.349066
30 0.523599
40 0.698132
50 0.872665
60 1.047198
70 1.221731
80 1.396264
90 1.570796
100 1.745329
110 1.919862
120 2.094395
130 2.268928
140 2.443461
150 2.617994
160 2.792527
170 2.967060
180 3.141593
190 3.316126
200 3.490659
210 3.665192
220 3.839725
230 4.014258
240 4.188791
250 4.363324
260 4.537857
270 4.712389
280 4.886922
290 5.061455
300 5.235988
310 5.410521
320 5.585054
330 5.759587
340 5.934120
350 6.108653
360 6.283186
を出力をリダイレクトして送信するために./assign1> prog1.cを使用エラーメッセージが表示されます。
prog1.c:1:1: error: unknown type name âDegreesâ
Degrees to Radians
^
prog1.c:1:12: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âRadiansâ
Degrees to Radians
^
私はCプログラミングに新しいですし、まだエラーメッセージを理解する問題を抱えて、いずれかが実際に私のエラーメッセージを理解できますか?
ソースファイルにリダイレクトすると、元のソースファイルが最初のプログラムの出力で上書きされます。おそらく、最初のプログラムの出力を第2の(コンパイルされた)プログラムにパイプすることを意図していたのですが、 './assign1 | 。/ prog1' –