我的程序能在VC6.0,运行起来,但在VS2012里出现了这种情况Why?
vs2012吧
全部回复
仅看楼主
level 1
2014年10月16日 07点10分 1
level 1
这是我到那里就运行不了的函数
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define W 10
#define N 19
#define LEN sizeof(WORD)
typedef struct wo{ /*链表节点*/
char word[20];
int n;
struct wo *next;
struct wo *last;
}WORD;
int compare(char m[],WORD *head){ /*比较所取的词是否与已统计的词一致,如一致则加一,否则,返回信号量提醒新添结点*/
WORD *p;
int i=1;
p=head;
while(p!=NULL){
if(strcmp(m,p->word)==0){
(p->n)++;
i=0;
break;
}
p=p->next;
}
return i;
}
WORD *add(char m[]){
WORD *newptr;
newptr=(WORD *)malloc(LEN);
strcpy(newptr->word,m);
newptr->n=1;
newptr->next=NULL;
return newptr;
}
WORD *create(FILE *f){ /*分词,建链表*/
WORD *head=NULL,*newptr=NULL,*tail=NULL;
int i,s,n1=0,count=0;
char ch,m[20];
m[0]=*\0*;
do{
ch=fgetc(f);
i=isalpha(ch);
if(i!=0){
if(ch>=*A*&&ch<=*Z*){
ch=ch
+3
2;
}
m[n1]=ch;
++n1;
}
else{
if(m[0]!=*\0*){
m[n1]=*\0*;
++count;
if(count==1){
newptr=add(m);
newptr->last=NULL;
head=newptr;
tail=newptr;
}
else{
s=compare(m,head);
if(s!=0){
newptr=add(m);
tail->next=newptr;
newptr->last=tail;
tail=newptr;
}
}
strset(m,*\0*);
}
n1=0;
}
}while(ch!=EOF);
return head;
}
int main(){
FILE *fl;
WORD *head;
fl=fopen("C:\\jane.txt","r+");
if(fl==NULL){
printf("无法打开文件,请重新输入!\n");
}
else{
printf("成功打开文件!\n");
}
head=create(fl);
printf("PFZ");
fclose(fl);
}
2014年10月16日 10点10分 2
level 1

2014年10月16日 10点10分 3
1