linux代码windows能跑吗,能不能帮忙改一下下面这些代码,原来是在windows系统上运行的,要让它能在linux上终端跑。该如何处理...

当前位置:我的异常网» C语言 » 能不能帮忙改一下下面这些代码,原来是在windows系

能不能帮忙改一下下面这些代码,原来是在windows系统上运行的,要让它能在linux上终端跑。该如何处理

www.myexceptions.net  网友分享于:2013-04-13  浏览:10次

能不能帮忙改一下下面这些代码,原来是在windows系统上运行的,要让它能在linux上终端跑。

#include "stdio.h"

#include"stdlib.h"

#include"string.h"

#define LEN sizeof(struct word)

int main(int argc,char *argv[])

{

int i = 0;

FILE *fp;

char ch;

char string[50];

int len = 1;

int equal = 0;

int size = 0;

int max;

struct word

{

char str[50];

int num;

struct word *next;

struct word *pre;

};

struct word *list,*temp;

struct word *head,*com;

struct word *pre,*next,*wrap,*sea;

if(argc!= 2)

{

printf("输入格式不对,正确的格式为testWord filename!!!\n");

exit(0);

}

fp = fopen(argv[1],"r");

if(fp == NULL)

{

printf("文件打开错误!!!\n");

exit(0);

}

head = NULL;

list = temp = (struct word *)malloc(LEN);

ch = fgetc(fp);

for(i = 0;i<50;i++)

{

string[i] = '\0';

}

//读取文件,获取单词并统计该单词出现的次数

while(ch!=EOF)

{

if(!((ch >='A'&&ch<='Z')||(ch>='a'&&ch<='z')))

{

//判断单词是否已经出现过,出现过num+1,没出现的新增一个节点

if((string[0] >='A'&&string[0]<='Z')||(string[0]>='a'&&string[0]<='z'))

{

if(head != NULL)

{

com = head;

do

{

if(strcmp(string,com->str) == 0)

{

equal = 1;

break;

}

com = com->next;

}

while(com != NULL);

}

if(equal == 1)

{

//进行插入排序,如果数量增加,则调整相应的位置

com->num += 1;

equal = 0;

sea = head;

do

{

if(sea->num < com->num)

{

if(sea == head)

{

com->pre->next = com->next;

com->next->pre = com->pre;

com->pre = NULL;

com->next = sea;

sea->pre = com;

head = com;

}

else

{

pre = sea->pre;

pre->next = com;

sea->pre = com;

com->pre->next = com->next;

com->next->pre = com->pre;

com->pre = pre;

com->next = sea;

}

break;

}

sea = sea->next;

}

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值