⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getvec.c

📁 电力系统分析计算 学习调试程序 UNIX / LINUX / CYGWIN 系统使用
💻 C
字号:
/* Transform e-vector to SMMS format */#ifndef WINDOWS#include <stdio.h>#else#include "pfwstdio.h"#endif#include <math.h>#include <stdlib.h>#include <string.h>#include "constant.h"#include "param.h"#ifdef ANSIPROTOvoid ErrorStop(char *Msg);void ErrorHalt(char *Msg);int main(int argc,char **argv);#elsevoid ErrorStop();void ErrorHalt();int main();#endif/* ---------------------- ErrorStop ------------------------------------ */#ifdef ANSIPROTOvoid ErrorStop(char *Msg)#elsevoid ErrorStop(Msg)char *Msg;#endif{  fprintf(stdout,"Transform PoC e-vectors to SMMS format (c)1992 C. Canizares\n");  if (!NullName(Msg)) fprintf(stdout,"Error: %s\n",Msg);  fprintf(stdout,"Usage: getvec [-h] [<]input_file [>]output_file\n");  fprintf(stdout,"       Program to transform PoC e-vectors to SMMS old vector format.\n");  fprintf(stdout,"       The input_file is assumed to be in I Var Value format, which is\n");  fprintf(stdout,"       similar to the standard SMMS I J Value format.  If this file\n");  fprintf(stdout,"       is missing, the program reads from standard input.\n");  fprintf(stdout,"       The output_file is optional; the program writes to standard output\n");  fprintf(stdout,"       by default in I Val format.\n");  fprintf(stdout,"Options: -h     Prints this message.\n");  if (!NullName(Msg)) exit(ERROREXIT); else exit(NORMALEXIT);}/* ===================== ErrorHalt ================================ */#ifdef ANSIPROTOvoid ErrorHalt(char *Msg)#elsevoid ErrorHalt(Msg)char *Msg;#endif{  fprintf(stderr,"Error: %s\n",Msg);  exit(ERROREXIT);}/* --------------------------- Main Program  ------------------------------ */#ifdef ANSIPROTOint main(int argc,char **argv)#elseint main(argc,argv)int argc;char **argv;#endif/* Transform e-vector format */{  char *Name,var[20],Line[BUFLEN];  VALUETYPE val;  FILE *In,*Out;  INDEX i;  SetArguments(argc,argv);  if (HelpRequested()) ErrorStop("");  In=(FILE *) OpenInput(TrueParamStr(1));  Out=(FILE *) OpenOutput(TrueParamStr(2));  if (fgets(Line,BUFLEN,In)==NULL) ErrorStop("Wrong input data.");  for (;;) {    if (fgets(Line,BUFLEN,In)==NULL) ErrorStop("Wrong input data: Check for 0 0 0 line.");    if(sscanf(Line,"%d %s %lf",&i,var,&val)!=3) ErrorStop("Wrong input data:  Check input data format.");    else if (i) {      fprintf(Out,"%4d %-11.5g\n",i,val);    } else break;  }  fprintf(Out,"0 0.0\n");  fclose(Out);  return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -