免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123
最近访问板块 发新帖
楼主: hellolinux
打印 上一主题 下一主题

在linux下编写的shell怎么可以弄到xp下运行. [复制链接]

论坛徽章:
0
21 [报告]
发表于 2005-06-01 16:22 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

不好意思,再次麻烦
cc 1.c
1.c: In function `save2file':
1.c:64: warning: assignment makes pointer from integer without a cast

cat 1.c
#include <stdio.h>
#include <malloc.h>
#include <string.h>

struct fapiao{
   char fp[30];
   struct fapiao *next;
};
typedef struct fapiao FAPIAO;

main()
{
  char fpstr[30];
  FAPIAO *head;

  void insert(FAPIAO **,char *);
  void save2file(FAPIAO **,char *);

  head=NULL;
  while (1)
  {
    printf("lease enter the fapiao serial number,exit program with string \"exit\":\n";
    scanf("%s",fpstr);
    if (strcmp(fpstr,"exit"==0) break;
    insert(&head,fpstr);
  }
  printf("lease enter the file name for save datas:\n";
  scanf("%s",fpstr);
  save2file(&head,fpstr);
}

void insert(FAPIAO **head,char *string)
{
   FAPIAO *cur,*pre,*new;
   
   if ((new=(FAPIAO *)malloc(sizeof(FAPIAO)))==NULL)
      {printf("Can't creat new node!\n";return;}
   strcpy(new->fp,string);
   new->next=NULL;
   pre=*head;
   if (pre==NULL)
      *head=new;
   else
      {cur=pre;
       while(cur!=NULL)
          {if(strcmp(string,cur->fp)==0)
              {printf("Repeated!\n";return;}
           pre=cur;
           cur=cur->next;
          }
       pre->next=new;
       return;
      }
}

void save2file(FAPIAO **head,char *string)
{
FAPIAO *cur,*pre;
FILE *fptr;

pre=*head;
if (pre==NULL) return;
cur=pre;
if (fptr=fopen(string,"w"==NULL)
    {printf("Can't creat file!\n";return;}
while (cur!=NULL)
   {fprintf(fptr,"%30s\n",cur->fp);
      *head=cur;
      cur=cur->next;
      free(pre);
      pre=*head;
   }

fclose(fptr);
return;
}

论坛徽章:
0
22 [报告]
发表于 2005-06-01 16:23 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

cc 1.c
1.c: In function `save2file':
1.c:64: warning: assignment makes pointer from integer without a cast
ls
1~  1.c  1.c~  1.sh  1.sh~  a.out  bin  Desktop  first  mv  string  study  公证登记表
./a.out
Please enter the fapiao serial number,exit program with string "exit":
1
Please enter the fapiao serial number,exit program with string "exit":
2
Please enter the fapiao serial number,exit program with string "exit":
3
Please enter the fapiao serial number,exit program with string "exit":
4
Please enter the fapiao serial number,exit program with string "exit":
3
Repeated!
Please enter the fapiao serial number,exit program with string "exit":
exit
Please enter the file name for save datas:
ttt
段错误
[root--680--~]ls
1~  1.c  1.c~  1.sh  1.sh~  a.out  bin  Desktop  first  mv  string  study  ttt  公证登记表
[root--681--~]cat ttt
[root--682--~]
ttt为空

论坛徽章:
0
23 [报告]
发表于 2005-06-01 16:39 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

if (fptr=fopen(string,"w"==NULL)
少了个括号。
if ((fptr=fopen(string,"w")==NULL)

论坛徽章:
0
24 [报告]
发表于 2005-06-01 16:47 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

good,最后一个小问题.
当程序到
Please enter the file name for save datas:
aaa
怎么退不出来.
然后ctrl+C才可以退出来.
查看aaa时,有正确的信息.

论坛徽章:
0
25 [报告]
发表于 2005-06-01 16:56 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

你找找,我这里跑得好好的啊。可以正常推出啊。

论坛徽章:
0
26 [报告]
发表于 2005-06-01 16:58 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

不会是linux版本的问题吧.
uname -a
Linux nxgzserver 2.4.21-4.ELsmp #1 SMP Fri Oct 3 17:52:56 EDT 2003 i686 i686 i38 6 GNU/Linux

论坛徽章:
0
27 [报告]
发表于 2005-06-01 17:00 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

能和你交个朋友吗?
QQ:28460304
homepage and bbs : www.hellolinux.net

论坛徽章:
0
28 [报告]
发表于 2005-06-01 17:05 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

qq 316576715

论坛徽章:
0
29 [报告]
发表于 2005-06-01 17:55 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

这个程序怎么弄到xp下执行?

论坛徽章:
0
30 [报告]
发表于 2005-06-02 13:43 |只看该作者

在linux下编写的shell怎么可以弄到xp下运行.

哎,咋不用c++呢,看用c整的,多烦啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP