加油!!

LR脚本练习2

上一篇 / 下一篇  2010-12-03 09:45:25

1、循环读取并显示该文件中的每行数据:(只能读数字内容)
 
  1. Action(){   
  2.      int MyFile;    
  3.      int loadNum,i;   
  4.       // Assigning the file path to a string  
  5.      char FileName[80] ="C:\\temp\\solem.txt";      
  6.      // Opening the file  
  7.      // Note the use of variable to replace the file path  
  8.     MyFile = (int)fopen(FileName,"r");     
  9.      while ( feof(MyFile)==0) {   
  10.      fscanf(MyFile,"%d",&loadNum);   
  11.      lr_output_message("LoadNum----------------> :%d \n", loadNum);   
  12.      }   
  13.       return 0;   
  14. }  

2、循环读取并显示该文件中的每行数据:
 
  1. Action() {   
  2. char line[100] ;   
  3. long file_stream;   
  4. char *filename = "C:\\temp\\solem.txt";   
  5. if ((file_stream = fopen(filename, "r")) == null ) {      
  6.  lr_error_message("Cannot open %s", filename);   
  7. return -1;   
  8.   }   
  9.    while ( fgets(line, 100, file_stream)!= null) {   
  10.    lr_output_message( "The line is \"%s\"", line);   
  11. }   
  12. if (fclose(file_stream))   
  13.  lr_error_message("Error closing file %s", filename);   
  14. return 0;   

TAG:

 

评分:0

我来说两句

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 15450
  • 日志数: 40
  • 建立时间: 2008-11-13
  • 更新时间: 2011-03-29

RSS订阅

Open Toolbar