看看我用shell写的C语言脚本哪里出了问题?
执行时候说文件结尾有问题??由于换了系统是乱码。所以下面的****都代表 中文字符。可能有些符号是中文全角符号,也请多多包含~~~
下面是我的代码:
(1)shell部分:
#!/bin/bash
#c成绩存取系统(001.sh)
echo '********'
echo -e '\t\t**********\n'
echo -e '\t\t***********\n'
read A
./03.out
echo -e '\t\t\t1.*******\n'
echo -e '\t\t\t2.********\n'
echo -e '\t\t\t3.**********\n'
echo -e '\n\n*************:'
read B
if ($B=1)
then (echo '******************\n'
read C
./2.out > $C)
else
if ($B=2)
then (echo '****************\n'
read D
./1.out < $D)
else echo '*********'
fi
(2)01.c部分:
#include <stdio.h>
#define MAX 10
int main (void)
{
system ("cls");
int number;
char sex;
char name[MAX];
float Chinese, Maths, English;
scanf ("%d", &number);
while (number >= 0)
{
printf ("%6d", number);
getchar ();
scanf ("%c", &sex);
printf ("%6c", sex);
scanf ("%s", name);
printf ("%15s", name);
scanf ("%f", &Chinese);
printf ("%6.1f", Chinese);
scanf ("%f", &Maths);
printf ("%6.1f", Maths);
scanf ("%f", &English);
printf ("%6.1f", English);
printf ("\n");
scanf ("%d", &number);
}
printf ("*************\n");
return 0;
}
(3)02.c部分
#include <stdio.h>
#define MAX 10
int main (void)
{
system ("cls");
int number;
char sex;
char name[MAX];
float Chinese, Maths, English;
printf ("**********\n");
scanf ("%d", &number);
while (number >= 0)
{
printf ("%6d", number);
getchar ();
printf ("*********\n");
scanf ("%c", &sex);
printf ("%6c", sex);
printf ("****************\n");
scanf ("%s", name);
printf ("%15s", name);
printf ("**************\n");
scanf ("%f", &Chinese);
printf ("%6.1f", Chinese);
printf ("***************\n");
scanf ("%f", &Maths);
printf ("%6.1f", Maths);
printf ("***************\n");
scanf ("%f", &English);
printf ("%6.1f", English);
printf ("\n");
printf ("*******\n");
scanf ("%d", &number);
}
printf ("************\n");
return 0;
}