- 论坛徽章:
- 0
|
我这边改了是可以的
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<limits.h>
- int main(int argc,char *argv[]){
- FILE *fSource,*fIntermediate,*fSymTable;
- unsigned int sic_length=0;
- char name[1][128];
- char pathIntermediate[256],pathSymbolTable[256];
- char cwdBuffer[PATH_MAX];
- printf("(2005.Dec.10) sic1.c Released!!\n");
- printf("(2007.May.10) sic1.c Fixed!!\n");
- printf("Author's Website: http://tw.myblog.yahoo.com/mjshya/\n\n");
- if(argc!=2){
- printf("Input SIC source file name: ");
- scanf("%s",&name[0]);
- argv[1]=name[0];
- }
- fSource=fopen(argv[1],"r");
- if(fSource==NULL){
- printf("Open Source File Failure!!\n");
- printf("Check Files Please!!\n");
- system("pause");
- exit(0);
- }
- getcwd(cwdBuffer,PATH_MAX);
- strcpy(pathIntermediate,cwdBuffer);
- strcat(pathIntermediate,"\\intermed\\interMed.txt");
- strcpy(pathSymbolTable,cwdBuffer);
- strcat(pathSymbolTable,"\\intermed\\symTable.txt");
- mkdir("intermed");
- fIntermediate=fopen(pathIntermediate,"w");
- fSymTable=fopen(pathSymbolTable,"w");
- if(fSource!=NULL||fIntermediate!=NULL||fSymTable!=NULL){
- if((sic_length=funPassFirst(fSource,fIntermediate,fSymTable))!=-1){
- fclose(fSource);
- fclose(fSymTable);
- fclose(fIntermediate);
- printf("...Address Completed!!\n");
- }else{
- fclose(fSource);
- fclose(fIntermediate);
- fclose(fSymTable);
- system("pause");
- exit(0);
- }
- }else{
- printf("Open Source, Destination and Symbol_Table Files Failure!!\n");
- printf("Check Files Please!!\n");
- system("pause");
- }
- return 0;
- }
复制代码
不过奇怪的是在limits.h中没看到定义
- $ grep PATH_MAX /usr/include/*.h
- /usr/include/stdlib.h: name is PATH_MAX chars or more, returns null with `errno' set to
- /usr/include/stdlib.h: ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
- /usr/include/unistd.h: BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
- $
复制代码 |
|