ログイン
kid's world

ファイルへの書き込み

Fig.1

/c/file-fig1.png

FILE *fp;
#include <stdio.h>
#include <stdlib.h>

main()
{
  FILE *fp;

  if((fp=fopen("file.txt","w")) == NULL) {
    exit(1);
  }
  

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

main()
{
  FILE *fp;
  
  if ((fp=fopen("c:\\", "w")) == NULL) {
    exit(1);
  }
  
  fclose(fp);
}

/c/file-fig2.png

fp=fopen("c:\txt\test.txt","w");
fp=fopen("c:\\txt\\test.txt","w");
fclose(fp);
#include <stdio.h>
#include <stdlib.h>

main()
{
  int y,m,d;
  FILE *fp;
  
  if ((fp=fopen("days.txt","w")) == NULL) {
    exit(1);
  }
  
  for(y=2000; y<=2010; y++){
    for(m=1; m<=12; m++){
      
      switch(m){
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
        d=31;
        break;
      case 4:
      case 6:
      case 9:
      case 11:
        d=30;
        break;
    case 2:
      if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
        day=29;
      else
        day=28;
      }
      
    }
  }
  fclose(fp);
}

/c/file-fig3.png


広告


©Toshio Koide 1996-2007.

mail.gif

広告