- 论坛徽章:
- 0
|
我用SSHClient连上linux服务器,然后在上面运行程序,写了一个很简单的代码,但是一运行到下面那段就出现“娈甸璇”字符为什么啊?代码按理说没问题吧。先谢谢大家的指点啦!
void eidt (void)
{
char eidt_number_button;
eidt_show_mes ();
for ( ; ; )
{
eidt_number_button = getchar ();
switch (eidt_number_button)
{
case '1':
{
edit_add (); //错误就是在这里产生的,都没有进这个子程 序, //因为我在子程序中开头打印消息都没有显示,
eidt_show_mes();
break;
}
void edit_add (void)
{
Book *add_book;
add_book = (Book *) malloc (sizeof (Book));
init_book (add_book);
char _continue[10];
FILE *fp;
fp = fopen (FILE_PATH, "a+");
if(!fp)
{
printf ("Open file failed!\n");
return ;
}
for ( ; ; )
{
printf ("Please enter the book's title: ");
myscanf (add_book->Title);
printf ("Please enter the book's author: ");
myscanf (add_book->Author);
printf ("Please enter the book's Category: ");
myscanf (add_book->Category);
//printf ("Please enter the book's Status: ");
//myscanf (add_book->Status);
printf ("Please enter the book's Price: ");
myscanf (add_book->Price);
printf ("Please enter the book's print date: ");
myscanf (add_book->P_Date);
fprintf (fp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\r\n", add_book->Title, add_book->Author, add_book->Category ,add_book->Status, add_book->Price, add_book->P_Date, add_book->Borrower, add_book->B_Date);
L: printf ("continue to add? (yes/no)");
scanf ("%s", _continue);
if (strcmp (_continue, "no") == 0) break;
else if (strcmp (_continue, "yes") == 0) continue;
else goto L;
}
fclose (fp);
return ;
} |
|