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

📄 moverel .txt

📁 从流中执行格式化输入 从流中执行格式化输入 从流中执行格式化输入
💻 TXT
字号:
函数名: vfprintf 
功  能: 送格式化输出到一流中 
用  法: int vfprintf(FILE *stream, char *format, va_list param); 
程序例: 

#include <stdio.h> 
#include <stdlib.h> 
#include <stdarg.h> 

FILE *fp; 

int vfpf(char *fmt, ...) 
{ 
   va_list argptr; 
   int cnt; 

   va_start(argptr, fmt); 
   cnt = vfprintf(fp, fmt, argptr); 
   va_end(argptr); 

   return(cnt); 
} 

int main(void) 
{ 
   int inumber = 30; 
   float fnumber = 90.0; 
   char string[4] = "abc"; 

   fp = tmpfile(); 
   if (fp == NULL) 
   { 
      perror("tmpfile() call"); 
      exit(1); 
   } 

   vfpf("%d %f %s", inumber, fnumber, string); 
   rewind(fp); 
   fscanf(fp,"%d %f %s", &inumber, &fnumber, string); 
   printf("%d %f %s\n", inumber, fnumber, string); 
   fclose(fp); 

   return 0; 
} 
  
  
  

函数名: vfscanf 
功  能: 从流中执行格式化输入 
用  法: int vfscanf(FILE *stream, char *format, va_list param); 
程序例: 

#include <stdio.h> 
#include <stdlib.h> 
#include <stdarg.h> 

FILE *fp; 

int vfsf(char *fmt, ...) 
{ 
   va_list  argptr; 
   int cnt; 

   va_start(argptr, fmt); 
   cnt = vfscanf(fp, fmt, argptr); 
   va_end(argptr); 

   return(cnt); 
} 

int main(void) 
{ 
   int inumber = 30; 
   float fnumber = 90.0; 
         char string[4] = "abc"; 

   fp = tmpfile(); 
   if (fp == NULL) 
   { 
      perror("tmpfile() call"); 
      exit(1); 
   } 
   fprintf(fp,"%d %f %s\n",inumber,fnumber,string); 
   rewind(fp); 

   vfsf("%d %f %s",&inumber,&fnumber,string); 
   printf("%d %f %s\n",inumber,fnumber,string); 
   fclose(fp); 

   return 0; 
} 
  
  

函数名: vprintf 
功  能: 送格式化输出到stdout中 
用  法: int vprintf(char *format, va_list param); 
程序例: 

#include <stdio.h> 
#include <stdarg.h> 

int vpf(char *fmt, ...) 
{ 
   va_list argptr; 
   int cnt; 

   va_start(argptr, format); 
   cnt = vprintf(fmt, argptr); 
   va_end(argptr); 

   return(cnt); 
} 

int main(void) 
{ 
   int inumber = 30; 
   float fnumber = 90.0; 
   char *string = "abc"; 

   vpf("%d %f %s\n",inumber,fnumber,string); 

   return 0; 
} 
  
  

函数名: vscanf 
功  能: 从stdin中执行格式化输入 
用  法: int vscanf(char *format, va_list param); 
程序例: 

#include <stdio.h> 
#include <conio.h> 
#include <stdarg.h> 

int vscnf(char *fmt, ...) 
{ 
   va_list argptr; 
   int cnt; 

   printf("Enter an integer, a float,  and a string (e.g. i,f,s,)\n"); 
   va_start(argptr, fmt); 
   cnt = vscanf(fmt, argptr); 
   va_end(argptr); 

   return(cnt); 
} 

int main(void) 
{ 
   int inumber; 
   float fnumber; 
   char string[80]; 

   vscnf("%d, %f, %s", &inumber, &fnumber, string); 
   printf("%d %f %s\n", inumber, fnumber, string); 

   return 0; 
} 
  
  
  

函数名: vsprintf 
功  能: 送格式化输出到串中 
用  法: int vsprintf(char *string, char *format, va_list param); 
程序例: 

#include <stdio.h> 
#include <conio.h> 
#include <stdarg.h> 

char buffer[80]; 

int vspf(char *fmt, ...) 
{ 
   va_list argptr; 
   int cnt; 

   va_start(argptr, fmt); 
   cnt = vsprintf(buffer, fmt, argptr); 
   va_end(argptr); 

   return(cnt); 
} 

int main(void) 
{ 
   int inumber = 30; 
   float fnumber = 90.0; 
   char string[4] = "abc"; 

   vspf("%d %f %s", inumber, fnumber, string); 
   printf("%s\n", buffer); 
   return 0; 
} 
  
  
  

函数名: vsscanf 
功  能: 从流中执行格式化输入 
用  法: int vsscanf(char *s, char *format, va_list param); 
程序例: 

#include <stdio.h> 
#include <conio.h> 
#include <stdarg.h> 

char buffer[80] = "30 90.0 abc"; 

int vssf(char *fmt, ...) 
{ 
   va_list  argptr; 
   int cnt; 

   fflush(stdin); 

   va_start(argptr, fmt); 
   cnt = vsscanf(buffer, fmt, argptr); 
   va_end(argptr); 

   return(cnt); 
} 

int main(void) 
{ 
   int inumber; 
   float fnumber; 
   char string[80]; 

   vssf("%d %f %s", &inumber, &fnumber, string); 
   printf("%d %f %s\n", inumber, fnumber, string); 
   return 0; 
} 


函数名: moverel 
功  能: 将当前位置(CP)移动一相对距离 
用  法: void far moverel(int dx, int dy); 
程序例: 

#include <graphics.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   char msg[80]; 

   /* initialize graphics and local variables */ 
   initgraph(&gdriver, &gmode, ""); 

   /* read result of initialization */ 
   errorcode = graphresult(); 
   if (errorcode != grOk)  /* an error occurred */ 
   { 
      printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
      printf("Press any key to halt:"); 
      getch(); 
      exit(1); /* terminate with an error code */ 
   } 

   /* move the C.P. to location (20, 30) */ 
   moveto(20, 30); 

   /* plot a pixel at the C.P. */ 
   putpixel(getx(), gety(), getmaxcolor()); 

   /* create and output a message at (20, 30) */ 
   sprintf(msg, " (%d, %d)", getx(), gety()); 
   outtextxy(20, 30, msg); 

   /* move to a point a relative distance */ 
   /* away from the current value of C.P. */ 
   moverel(100, 100); 

   /* plot a pixel at the C.P. */ 
   putpixel(getx(), gety(), getmaxcolor()); 

   /* create and output a message at C.P. */ 
   sprintf(msg, " (%d, %d)", getx(), gety()); 
   outtext(msg); 

   /* clean up */ 
   getch(); 
   closegraph(); 
   return 0; 
} 

函数名: moveto 
功  能: 将CP移到(x, y) 
用  法: void far moveto(int x, int y); 
程序例: 

#include <graphics.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   char msg[80]; 

   /* initialize graphics and local variables */ 
   initgraph(&gdriver, &gmode, ""); 

   /* read result of initialization */ 
   errorcode = graphresult(); 
   if (errorcode != grOk)  /* an error occurred */ 
   { 
      printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
      printf("Press any key to halt:"); 
      getch(); 
      exit(1); /* terminate with an error code */ 
   } 

   /* move the C.P. to location (20, 30) */ 
   moveto(20, 30); 

   /* plot a pixel at the C.P. */ 
   putpixel(getx(), gety(), getmaxcolor()); 

   /* create and output a message at (20, 30) */ 
   sprintf(msg, " (%d, %d)", getx(), gety()); 
   outtextxy(20, 30, msg); 

   /* move to (100, 100) */ 
   moveto(100, 100); 

   /* plot a pixel at the C.P. */ 
   putpixel(getx(), gety(), getmaxcolor()); 

   /* create and output a message at C.P. */ 
   sprintf(msg, " (%d, %d)", getx(), gety()); 
   outtext(msg); 

   /* clean up */ 
   getch(); 
   closegraph(); 
   return 0; 
} 
  



⌨️ 快捷键说明

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